【问题标题】:My apk is not being installed in some mobiles while being installed in others我的 apk 没有安装在某些手机上,而安装在其他手机上
【发布时间】:2018-11-09 05:20:15
【问题描述】:

我制作了一个基于WebView 的应用程序,该应用程序安装在某些设备上,而未安装在其他设备上。我在 android 版本 4、6、7 上检查过。问题不在于 Android 版本。在某些设备中,它会显示Problem occurs when parsing the packageApplication package installer has stopped unexpectedly

注意:我在 Samsung j7 Prime、Mi A1 和其他一些产品中遇到了问题。但是小米Note 3、OPPO f3等都没有问题。

我做错了什么?这是我的activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent">

    <im.delight.android.webview.AdvancedWebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.MainActivity"
        android:id="@+id/webview">
    </im.delight.android.webview.AdvancedWebView>

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="id">
    </com.google.android.gms.ads.AdView>

</RelativeLayout>

这是我的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

这是我的build.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.rimikri.smartpedi"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        //OneSignal
        manifestPlaceholders = [
                onesignal_app_id: 'id',
                onesignal_google_project_number: 'REMOTE'
        ]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    compile 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
    compile 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
    compile 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.android.gms:play-services-ads:15.0.0'
    compile 'com.google.firebase:firebase-ads:15.0.0'
    implementation 'com.facebook.android:audience-network-sdk:4.27.1'
    implementation 'com.google.ads.mediation:facebook:4.27.1.0'
}

apply plugin: 'com.google.gms.google-services'

提前感谢您的建议。

【问题讨论】:

  • 发布你的 gradle 文件,你的 minSdk 级别是多少?
  • 谢谢。毕业典礼发布。我的最小 SDK 是 21 @EgeKuzubasioglu

标签: android build.gradle android-api-levels


【解决方案1】:

主要是android版本不同,

尝试在 manifest.xml 中定义您的最低和目标 android API 级别

例如

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />

【讨论】:

  • 它在什么设备上运行?你能列出来吗?
  • 三星 j7 Prime、Mi A1 和其他一些问题。小米 Note 3、Oppo f3 等都没有问题
  • 尝试使用 adb 安装?如果你这样做了,告诉我进展如何
【解决方案2】:

您的最低 sdk 级别为 21 minSdkVersion 21

你有可能只支持Android 5.0 (LOLLIPOP) 及以上的视图组件吗?您应该运行分析代码并检查不会导致任何运行时错误的 xml 错误

另外,您是否使用任何第三方库?其中一些可能指定了 minSdk 版本,它们可能低于您应用的 minSdk

【讨论】:

  • 我使用AdvancedWebView 作为 WebView 组件。还有一个 AdMob 组件。没有别的了。
【解决方案3】:

这可能是因为您尝试在 API 级别低于 21 的设备(即 Lollipop)上安装应用程序,并且您的应用程序的 minSdkVersion = "21"。 因此,要在低于 api 级别 21 的设备上使用应用程序,请将应用程序级别 build.gradle 文件中的应用程序的 minSdkVersion 降级为 16 (minSdkVersion = "16")。

【讨论】:

  • 他已经说过“我在安卓版本4、6、7上检查过。问题不在于安卓版本。”
【解决方案4】:

由于它适用于某些设备而不适用于其他设备,我很确定这是尺寸问题,您将图像或图标放在某处,它不适合某些设备尺寸

【讨论】:

  • 我已经检查了图标,它们没有引起问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 2010-10-11
  • 2019-08-27
相关资源
最近更新 更多