I have create one sample app using parse.com jar. In this project Buid version SDK was 22(it was running fine). But after change it with 23 I am facing some issues in compiling app. I have tried to clean project, Invalidate caches. Rebuild project etc but I faced same issue error is:FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.parse.ParseRequest
at com.parse.Parse.initialize(Parse.java:184) I can't get find exact solution. I have checked libs folder have jar. I have also tried with latest gradle code but faced same error. After removing parse jar I can compile my project. My dependencies are
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/org.apache.http.legacy.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile project(':MaterialShowcaseView')
compile files('libs/Parse-1.9.2.jar')
compile files('libs/bolts-android-1.2.0.jar')
compile files('libs/universal-image-loader-1.9.4.jar')
}
If I Change this dependencies with compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.12.0' then error is different. Error is:java.lang.NoClassDefFoundError: com.parse.ParsePlugins$1
at com.parse.ParsePlugins.restClient(ParsePlugins.java:92)
at com.parse.Parse.initializeParseHttpClientsWithParseNetworkInterceptors(Parse.java:762)
at com.parse.Parse.initialize(Parse.java:365)
at com.parse.Parse.initialize(Parse.java:344)
Please suggest me, what is wrong with this dependency. Thanks in advance
Issue is not because of parse class.In error you get that error because of mulitdex not handled & Initilization of parse is on app start up thats why it will give class not found error.
add below lines to build.gradle to handle multi dex
To resolve issue what i give in my build.gradle
dexOptions {
incremental true
// here heap size give 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
javaMaxHeapSize "4g"
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
// your dependencies which you are using.
}
Entire build.gradle
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
configurations {
// all*.exclude group: 'com.android.support', module: 'recyclerview-v7'
}
android {
signingConfigs {
/*
releasebuild {
keyAlias 'hellotest'
keyPassword 'hellotest'
storeFile file('path to keystore')
storePassword 'hellotest'
}
*/
}
compileSdkVersion 'Google Inc.:Google APIs:22'
buildToolsVersion '23.0.0'
/* if you got error regarding duplicate file of META-INF/LICENSE.txt from jar file
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
*/
dexOptions {
jumboMode = true
incremental true
// here heap size give 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
javaMaxHeapSize "4g"
}
defaultConfig {
multiDexEnabled true
applicationId "com.myapp.packagenme"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releasebuild
}
debug {
signingConfig signingConfigs.releasebuild
}
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
// your dependencies which you are using.
}
With the help of android developer multidex guide MultiDexApplication class
To install MultiDex.install i refer android developer link
public class MyAppClass extends MultiDexApplication{
#Override
protected void attachBaseContext(Context newBase) {
MultiDex.install(newBase);
super.attachBaseContext(newBase);
}
}
Suggestion
Selectively compiling APIs into your executable
Don't use entire google play service use only required library.From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
Let me know if anything.
Related
I developed an Android project with project name DemoMessageing, package name com.abc.xyz and added FCM to that project as created project in Firebase with package name com.abc.xyz for cloud messaging, applied SHA-1 and downloaded google-service.json. Put that .json in my app. I uploaded that project on Google Play also uploaded updates to the same.
Now i created new project in Firebase same package name com.abc.xyz but different project name as DemoMessageingTest. Removed the SHA-1 from old projectDemoMessageing) and applied same SHA-1 in new project(DemoMessageingTest) in Firebase. Download new google-service.json and place in my app.
Now i created signed apk and tried to upload on google play as a update for existing project. But google play is giving error as:
I increased the code version and again tried to upload the app on google play. But having same error.
My build.gradle is as below:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.abc.xyz"
minSdkVersion 16
targetSdkVersion 27
versionCode 8
versionName "8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support.constraint:constraint-layout:1.1.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.whereismytransport.transportapisdk:transportapisdk:1.0.1', {
exclude group: 'org.json', module: 'json'
}
compile('com.twitter.sdk.android:twitter:3.1.1#aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services-auth:10.2.1'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.squareup.picasso:picasso:2.4.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.7.0#aar') {
transitive = true;
}
compile project(':commonwidget')
compile project(':common')
compile project(':panowidget')
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
compile project(':emojilib')
compile files('libs/commons-lang-2.5.jar')
compile 'com.amazonaws:aws-android-sdk-core:2.2.13'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.13'
compile 'com.amazonaws:aws-android-sdk-ddb:2.2.13'
}
apply plugin: 'com.google.gms.google-services'
I am not able to understand what i am missing or what i am doing is right or not.
Please guide me with you suggestion and experience.
The error message tells you exactly what the error is.
You need to use a different version code for your APK or Android App Bundle because you already have one with version code 7
Your previous APK you uploaded with version code 7. If you keep the same package name, when you are uploading a new APK, you are sending an update to users. When an update happens, the version code must increase in your app. Increase your app version code (eg to 8), rebuild your APK, and the APK should upload fine.
I am struck by the problem I used all the google guideline to reduce the size of the apk. I also checked out many answers posted on StackOverflow but no one helps me to reduce the size of my apk. I don't know what the problem? I used shrinkResource, adaptations but these do not short out my issue
my Gradle file is:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
apply plugin: 'io.fabric'
android {
/* signingConfigs {
config {
keyAlias 'mykey'
keyPassword 'mykeyPassword'
storeFile file('D:/Brijesh/Project/All Project Keystore/MySkoda/mykey.jks')
storePassword 'mykeyPassword'
}
}*/
signingConfigs {
config {
keyAlias 'mykey'
keyPassword 'mykeyPassword'
storeFile file('D:/ajit/other/ex/Skoda/mykey.jks')
storePassword 'mykeyPassword'
}
}
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.skodaautoindia.myskoda"
minSdkVersion 17
targetSdkVersion 25
versionCode 8
versionName "1.1.0.5"
multiDexEnabled true
/* signingConfig signingConfigs.config*/
signingConfig signingConfigs.config
}
repositories {
mavenCentral()
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
/* release {
minifyEnabled false
signingConfig signingConfigs.config
}*/
}
aaptOptions {
cruncherEnabled = false
}
useLibrary 'org.apache.http.legacy'
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2#aar') {
transitive = true;
}
compile project(':photo-crop-library')
compile 'com.facebook.android:facebook-android-sdk:4.11.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:customtabs:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.google.code.gson:gson:2.5'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'cz.msebera.android:httpclient:4.4.1.1'
compile 'com.google.android.gms:play-services-plus:11.0.2'
compile 'com.google.android.gms:play-services-auth:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.android.support:support-vector-drawable:25.4.0'
compile 'com.albinmathew:photo-crop-library:1.0.3'
compile 'com.android.support:multidex:1.0.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
}
apply plugin: 'com.google.gms.google-services'
Thank you very much for your time and assistance in this matter.
This can be usedful to you.
Use ProGaurd
try
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}}
shrinkResources true will not include the images from resources which your using in the final apk
Remove any debug info you have in the app ( statements such as Log.i()). They can be wrapped in a condition which is only enabled while testing out the application.
Use recommended media formats
Image: PNG or JPG
Audio: AAC
Video: H264 AVC
Compress images using OptiPNG or PNGCrush
Find unused resources using this tool and remove them.
Refrain using multiple resources to achieve the same functionality. The resources is not limited to images but can be extended to APIs. Sometimes, using a singular API which provide multiple results is more efficient than using two or three different APIs. Duplicated strings and assets are also a waste of mermory.
Also Refer this link: GitHub Reduce APK Size
An APK file consists of a ZIP archive that contains all the files that comprise your app. These files include Java class files, resource files, and a file containing compiled resources.
please recheck on your assets and res files.
Although you don't need to export your rasterized assets to each density.
link
Generate dependency tree for your included dependencies in app level build.gradle file
use exclude {} block for each of the repeating dependencies
Example:
compile ("com.xxx:xxx-commons:1.+") {
exclude group: 'junit', module: 'junit'
}
Now you can analyse your APK file in Android Studio 3.0+ By going "Build -> Analyse APK..."
There you will see the detailed information about your APK.
I'm getting the following error
Error:Execution failed for task
:app:transformClassesWithJarMergingForDebug.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/DebugUtils.class
I searched the entire day but couldn't found a proper answer which will solve my problem.
My app bulid gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.project.test"
multiDexEnabled true
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// depend files
dependencies
{
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-ads:+'
compile 'com.google.android.gms:play-services-identity:+'
compile 'com.google.android.gms:play-services-gcm:+'
compile files('libs/android-support-v4.jar')
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
}
I tried Clean and Rebuild, but that also not working.
Please help on this. Thanks in advance.
This issue happens when you add the same class twice.
In your project you are adding many times the support-v4 library.
remove android-support-v4.jar from libs folder
remove this line compile files('libs/android-support-v4.jar')
change the dependency of the library 'com.github.JakeWharton:ViewPagerIndicator:2.4.1' because it uses an old support-v4.jar
Use:
compile ('com.github.JakeWharton:ViewPagerIndicator:2.4.1') {
exclude module: 'support-v4'
}
After doing some research it seams that com.github.JakeWharton:ViewPagerIndicator:2.4.1 is already importing the android-support-v4.jar, from here your duplicate error. In order to fix it I recommend you to do the following changes:
remove android-support-v4.jar from libs folder
remove from gradle file the line compile files('libs/android-support-v4.jar').
Hope it fixes your problem.
I've just ported a legacy codebase from Eclipse/ADT to Android Studio. Process went quite fine, app is compiling and running without errors.
Now I'm trying to add Google Play Services (in order to use Analytics) to the app. I'm following the guide https://developers.google.com/analytics/devguides/collection/android/v4/ and I've added the compile instruction in build.gradle.
When I add the file google-services.json and try to compile, I receive an error related to the intermediate build generation for AppCompat and Material Design.
This is the error I receive then I do a gradle clean:
http://pastebin.com/GG7Pu7iu
This is my app's build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "23"
defaultConfig {
applicationId "com.mediana.myapp"
minSdkVersion 16
targetSdkVersion 19
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {
minifyEnabled false
}
}
packagingOptions {
exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}
}
dependencies {
compile files('libs/commons-codec-1.7.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/crittercism_v4_1_0.jar')
compile files('libs/svgAndroid2-src.3Jan2014.jar')
compile files('libs/gcm.jar')
compile files('libs/gson-2.2.4.jar')
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:gridlayout-v7:19.+'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}
apply plugin: 'com.google.gms.google-services'
I'll provide anything you need
Thanks in advance
I'm trying to use some libraries into my android project and I'm facing some problems with different libraries. I have a library which I import from maven repository that has "nineoldandroids" library dependency. After that I have another import that uses the same library and I did a exclude of that module. Now if I sync Gradle everything works fine but when I try to run my app I get the following error
"Error:Class com.nineoldandroids.animation.Animator.AnimatorListener has already been added to output. Please remove duplicate copies."
I think that both libraries are trying to use the same Listener and I get that error but I'm not able to solve it and I didn't find useful information for me. If somebody can help me I would appreciate it. This is my gradle file. BTW last library must be manually included and it's placed in my "libs" folder.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.infortec.acostela.pescamerca"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories{
jcenter()
flatDir {
dirs 'libs'
}
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.+'
compile "com.android.support:gridlayout-v7:18.0.+"
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'commons-net:commons-net:3.3'
compile 'net.sf.opencsv:opencsv:2.3'
compile 'com.rengwuxian.materialedittext:library:1.8.2'
compile ('libs.example:material:0.4.3#aar'){
exclude module: 'nineoldandroids'
}
}
Finally I solved it.
The problem was that I must exclude the whole library, not only the module so writing the following solved it.
compile ('com.rengwuxian.materialedittext:library:1.8.2'){
exclude group: 'com.nineoldandroids', module: 'library'
}