APK isn't installing on single devices - android

I have a problem is with installing my application on random devices. The app works on my phone (Android 6.0) and on emulator (7.1.1), but it can't be installed on friends' phones with e.g. same Android version or 5.0 probably. Is there any IDE-side reason (IntelliJ IDEA, earlier Android Studio with same error)?
There is fragment of build.gradle in my project. Maybe it'll help somehow...
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.pkgname"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "Pre-release"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
pre_release {
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Greetings!

Just you make debug-version your .apk. Look at - https://techtuts.info/2014/05/build-release-apk-android-studio/

Will you please let us know whether you're trying to use the build apk generated at the time of installing app directly to your know or you are creating a fresh build.
Note: if you want to support all devices as per your build config then you must have you create a clean build and then try to install app within your required devices.Hope it will help.

Related

No Class defined error on release builds?

I seem to be running into an issue where only release builds crash with the error java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit2/Retrofit$Builder; The class is irrelevant because it has not resolved other classes too in the release build. However, this does not appear on Debug builds which makes no sense at all. I have found that when I include these two dependencies:
implementation 'com.google.android.gms:play-services-ads:12.0.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.8.5'
the app crashes. However, when I exclude one of them, then the release builds work. Has anyone encountered this before?
The build config looks like this:
compileSdkVersion 26
buildToolsVersion 26.0.1
defaultConfig {
applicationId "xxxx"
minSdkVersion 21
targetSdkVersion 27
versionName project.rootProject.version.toString()
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig xxxx
}
}
Update your gradle
targetSdkVersion 27,
compileSdkVersion 27, and
buildtoolsVersion to 27.0.1 or remove it (leave it as default. gradle will always look for the latest within this version 27)
The above solved my problem too. Although, i don't use multiDexEnabled true as i see no reason why when i have google play service library included.
Try removing multiDexEnabled true and re-build gradle.
Unless your are class extending Application class.Then you can use multiDexEnable true
#Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
check this question for possible solution

App not installed after upgrading to Android - P

App is installing while connecting via USB to mobile, but while sending .apk file to others it saying "App not Installed"(both debug and release).I have tried different solutions from stackoverflow but none worked for me.
1.How to overcome app not installed error when building from Android Studio 3.0?
2.Cannot install signed apk to device manually, got error "App not installed"
3.Android Studio 3.0 Unsigned Apk Not Installing
Below is my build.gradle(app level)
android {
compileSdkVersion 'android-P'
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "XXXXXXX"
minSdkVersion 15
targetSdkVersion 26
versionCode 51
versionName "1.51"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions{
disable 'MissingTranslation'
}
}
Please help me on this.Thanks in Advance.
You can override testOnly flag adding following line to gradle.properties:
android.injected.testOnly=false
Android P preview SDK is a preview and you should not be distributing APKs built with it. Use a non-preview SDK for compiling APKs that are meant for other people to use.
Technically, the installation limitation is that the APKs have testOnly flag set to true. To work around that, see ADB Install Fails With INSTALL_FAILED_TEST_ONLY

Android JACK compiler error after upgrade to latest support library

--Android Studio 2.2.3 (Windows 10 64 bit)
--Build Tools version 25
--Android Gradle Plugin Version 2.2.3
After upgrade to latest support libraries (25.1.0 from 23.4.0) and change of compile version (25 from 23) I get this error:
Error:com.android.sched.util.config.PropertyIdException: Property 'jack.library.import' (in Options): element #7: The version of the library file '..\app\build\intermediates\transforms\preJackPackagedLibraries\debug\jars\8000\1f\classes-1b6639e8217419d056942b0dacd1542739f1709f.jar' is not supported anymore. Library version: 3.2 - Current version: 3.3 - Minimum compatible version: 3.3
...
BUILD FAILED
Has anyone ever had this problem? In the mentioned .jar file I can find some AnimatedVectorDrawble related files. My app build.gradle
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "package"
minSdkVersion 14
targetSdkVersion 25
versionCode 111
versionName "1.1.1"
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
jackOptions.enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
maxProcessCount 4
javaMaxHeapSize "2g"
}
buildTypes {
release {
minifyEnabled false
useProguard false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
useProguard false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".dev"
versionNameSuffix "-DEV"
ext.enableCrashlytics = false
}
}
}
Based on the error message, it appears that Jack-enabled builds do not handle all cases where you update Gradle build settings. Jack keeps a cache of pre-compiled stuff (preJackPackagedLibraries), and something that you changed caused Jack to not like that pre-compiled material. Ideally, the build system would detect this case and simply re-compile it, but apparently it does not.
Cleaning the project (Build > Clean Project) hopefully clears up this problem in all cases.

Android Gradle 2.2 Not Allowing ShrinkResources for Signed APK

As part of the Android Studio 2.2 roll out I updated my Gradle Build tools to v2.2. After doing that my signed APK build process fails because I have shrinkResources = true.
Once I switch back to Gradle v2.1.3 OR set shrinkResources = false everything works fine. Here's my app gradle build file:
android {
signingConfigs {
}
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
applicationId "com.sample.testapp"
minSdkVersion 21
targetSdkVersion 24
versionCode 4
versionName "0.0.4"
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'C:/Users/code/testapp/app/proguard-rules.pro'
}
}
productFlavors {
}
}
With Gradle set to v2.2 here's the build error I get when generating a signed APK
Does anyone know why this is occurring and if there's a work around? I've Googled around a bit and have seen some older Android Bug reports about alpha and beta Gradle builds having this issue, but the reports I found were >6 months old (and for previous Gradle versions).
P.S. I know that minifyEnabled = false currently, i have yet to investigate the correct set of proguard rules for my included libraries to prevent the Signed Build from erroring out due to missing libs.
To use shrinkResources you have to use minifyEnabled
As per Android documentation:
Resource shrinking works only in conjunction with code shrinking.
After the code shrinker removes all unused code, the resource shrinker
can identify which resources the app still uses. This is especially
true when you add code libraries that include resources—you must
remove unused library code so the library resources become
unreferenced and, thus, removable by the resource shrinker.
To enable resource shrinking, set the shrinkResources property to true
in your build.gradle file (alongside minifyEnabled for code
shrinking).
use
minifyEnabled false
shrinkResources false
or
minifyEnabled true
shrinkResources true
may be a bug on android gradle plugin
wait google fix bugs

Unable to zipalign apk android android studio 2.2

I am publishing my app using android studio 2.2 preview 3 and generating signed apk. But when i am uploading apk to google play i am getting error
You uploaded an APK that is not zip aligned. You will need to run a zip align tool on your APK and upload it again.
Also i tried to used zipalign tool manually but i am getting error verification failed.
Here is my build.gradle file
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "blackdogs.newaomsi"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
zipAlignEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}
Got it. Error was due to gradle version i was using.
Downgraded gradle version to
'com.android.tools.build:gradle:2.1.2'
This is a known issue with Android Studio 2.2 Preview 3, as explained in this blog post and this issue.
You have to download Preview 2 or use the stable version of Android Studio.
solved in the next release
classpath 'com.android.tools.build:gradle:2.2.0-alpha4'
reference link:https://code.google.com/p/android/issues/detail?id=212591

Categories

Resources