2

I am able to successfully build APK file in Android studio by selecting minimum Android version is 5.0 (Lollipop) as part of creating android project in Android studio.

But when i try to install APK in Android mobile ( 5.0 version), it gives Package Parsing error.

i have also set minifyEnabled to true

i have noticed that Android studio includes "compile 'com.android.support:appcompat-v7:24.2.0" though i select minimum version is Lollipop (5.0) . V24.2.0 is for marshmallow.

any expert help me on this

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

enter code here

   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'
    }
user1439582
  • 103
  • 2
  • 14

2 Answers2

2

I got this error while building the android application

  1. I made changes into build.gradle file(change 24.2.0 to 23.0.0) or change the version number.

    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'
         }
    
  • http://stackoverflow.com/questions/29682002/error-on-installing-apk-parsing-the-package – Nancy thakkar Aug 23 '16 at 10:03
  • or its version issue. My target was 6.0. mean while my phone was 5.0.0. I changed the target version in my project and its works fine. Thanks – Nancy thakkar Aug 23 '16 at 10:04
  • any idea why android studio adds com.android.support:appcompat-v7:24.2.0 automatically when selecting minversion is 5.0 – user1439582 Aug 23 '16 at 10:27
  • Yes because of latest update https://developer.android.com/topic/libraries/support-library/revisions.html – Nancy thakkar Aug 23 '16 at 10:31
  • 23.0.0 for Marshmallow not for Lollipop – user1439582 Aug 23 '16 at 10:37
  • Then add a Lollipop version :) – Nancy thakkar Aug 23 '16 at 10:41
  • Marshmallow I have added for target version. – Nancy thakkar Aug 23 '16 at 10:42
  • will do. I am confused with this .in build.gradle we add minSdkVersion 14 targetSdkVersion 23. but dependency compile 'com.android.support:appcompat-v7:23.0.0' for target version only what about for 5.0 , should we are dependency for both 14 and 23. or 23.0.0. is backward compatible – user1439582 Aug 23 '16 at 10:48
  • http://stackoverflow.com/questions/26694108/what-is-the-difference-between-compilesdkversion-and-targetsdkversion – Nancy thakkar Aug 23 '16 at 10:54
  • Google detailed article - https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd#.mr0vup70u – Nancy thakkar Aug 23 '16 at 10:58
  • Hi Nancy i modified my build.gradle config and generated APK and tested on Lollipop android mobile and am still getting package parse error.but i tested on kitkat v4.1 mobile and it is working. any idea why it is not working in lollipop version i looked at the setting and i have selected option to allow unkown source any other setting – user1439582 Aug 24 '16 at 13:12
  • Delete all the previous version or all cache then reinstall apk or Check the permission. – Nancy thakkar Sep 09 '16 at 09:09
0

use the following code below the buildTypes in build.Gradle file

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

hope this will help you . Happy Coding....

Mr. Mad
  • 1,230
  • 1
  • 14
  • 28