通过选择最低 Android 版本为 5.0 (Lollipop) 作为在 Android studio 中创建 Android 项目的一部分,我能够在 Android studio 中成功构建 APK 文件。
但是当我尝试在 Android 手机(5.0 版本)中安装 APK 时,出现包解析错误。
我还将 minifyEnabled 设置为 true
我注意到 Android studio 包含“compile 'com.android.support:appcompat-v7:24.2.0”,尽管我选择的最低版本是 Lollipop (5.0) 。 V24.2.0 适用于棉花糖。
任何专家都可以帮助我
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
构建.gradle
在此处输入代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.simpletest"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
}
最佳答案
我在构建 Android 应用程序时遇到此错误
我对 build.gradle 文件进行了更改(将 24.2.0 更改为 23.0.0)或更改版本号。
defaultConfig { applicationId "your package name" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { preDexLibraries = false javaMaxHeapSize "4g" } packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } android { lintOptions { checkReleaseBuilds false } } defaultConfig { multiDexEnabled true } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.0.0' compile 'com.android.support:design:23.0.0' }
关于Android Studio gradle 构建兼容 Android – 5.0 Lollipop 等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39097807/