2016-08-23 74 views
2

我能够在Android studio中成功构建APK文件,通过选择最低Android版本为5.0(Lollipop)作为在Android Studio中创建Android项目的一部分。Android Studio gradle build for Android兼容Android - 5.0棒棒糖等

但是,当我尝试在Android移动(5.0版本)中安装APK时,它会给包解析错误。

我也成立minifyEnabled为true

我已经注意到了Android的工作室包括“编译“com.android.support:appcompat-v7:24.2.0" 虽然我选择最低版本是棒棒堂(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> 

的build.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' 
    } 
+0

完整build.gradle代码和AndroidManifest.xml –

+0

感谢您的帮助。我已更新 – user1439582

回答

2

我在构建Android应用程序

  1. 我所做的更改到的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' 
        } 
    
+0

http://stackoverflow.com/questions/29682002/error-on-installing-apk-parsing-the-package –

+0

或其版本问题。我的目标是6.0。意思是我的手机是5.0.0。我改变了我的项目中的目标版本,并且它的工作正常。谢谢 –

+0

任何想法为什么android studio在选择minversion 5.0时自动添加com.android.support:appcompat-v7:24.2.0 – user1439582

0

使用的build.gradle的buildTypes下面的下面的代码文件

packagingOptions { 
    exclude 'META-INF/NOTICE.txt' // will not include NOTICE file 
    exclude 'META-INF/LICENSE.txt' // will not include LICENSE file 
} 

希望这会帮助你。 快乐编码....