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
Related
I have an old volley configuration in my app. The app was built to target lollipop devices few years ago. I have also used an arcmenu library in same configuration like compile project('volley') and compile project('arcmenu').
Recently, I have reopened that project and tried running it again but it gives me this error:
Error: Configuration with name 'default' not found in Android Studio
I have installed all the previous platforms, from 21 to 26 in my sdk. Here's my gradle file
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "in.co.memoize"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'org.apache.httpcomponents:httpcore:4.3.2'
compile 'org.apache.httpcomponents:httpmime:4.3.2'
compile 'com.getbase:floatingactionbutton:1.5.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.github.markushi:circlebutton:1.1'
compile 'it.neokree:MaterialTabs:0.11'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.navercorp.pulltorefresh:library:3.2.0#aar'
compile 'com.github.orangegangsters:swipy:1.2.0#aar'
compile 'com.android.volley:volley:1.1.0'
//compile project(':volley')
compile project(':arcmenu')
}
After installing the platform versions, I get this message:
Error:Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
My settings.gradle file:
//include ':app', ':volley' commented to triangulate which library was
causing the problem but still not fixed
include ':app'
include ':arcmenu'
and arc menu gradle file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "21.1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Can anyone help me in resolving this issue? Thanks
I have fixed this by downloading and adding the dependencies as .aar/.jar files
I am trying to add in an older project google ads banner, but when I add to the Grandle the Firebase and run the app it crashes:
This is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com...."
minSdkVersion 15
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile files('libs/pinch-0.8.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/twitter4j-async-3.0.3.jar')
compile files('libs/twitter4j-core-3.0.3.jar')
compile files('libs/twitter4j-examples-3.0.3.jar')
}
apply plugin: 'com.google.gms.google-services'
and this is the error message
The first version of the project was developed with Eclipse.
This is because firebase uses new version of android support lib while actionbarsherlock relies on old version. If you still want to use actionbarsherlock you will need to make some changes into it, see here
do not forget to add main firebase project :
compile 'com.google.firebase:firebase-core:10.2.0'
Receving this error on KitKat and lower version running perfectly on Lollipop and above
I have included all the required jars in th gradle and Firebase json file to receive GCM.
my app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId ""
minSdkVersion 13
targetSdkVersion 23
versionCode 6
versionName "1.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':httpmime-4.2.5')
compile project(':universal-image-loader-1.9.3')
compile project(':universal-image-loader-1.9.3')
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.3'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
This dependency includes the code for all of the Google Play Services APIs:
compile 'com.google.android.gms:play-services:9.0.0'
This is very likely causing your app to exceed the 65K method reference limit, requiring you to use Multidex to run on pre-Lollipop devices.
You have two choices. You can include only the Play Services APIs you actually need. The list is here in the section titled Selectively compiling APIs into your executable. Or you can enable Multidex following the instructions here. Although you have multiDexEnabled true in your build.gradle file, that is only one of the three steps required to configure Multidex. You also need to include the library as a dependency and update your manifest.
If you are using Android Studio 2.2.2, you can see how many method references are in your app using the APK Analyzer. From the menubar, select Build > Analyze APK. The APK is in folder .../app/build/outputs/apk. Select the APK file, and in the resulting window, click on classes.dex to see the number of methods and method references.
Please update the firebase dependencies
dependencies {
...
compile 'com.google.firebase:firebase-messaging:9.6.0'
...
}
apply plugin: 'com.google.gms.google-services'
Hope it helps..
My app is working properly. There is no problem. i want to build generated signed apk. The problem is building take too long and completed with errors.
Please check the image. Thanks.
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
here my gradle;
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "umut.com.anyidea"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-messaging:9.6.0'
compile 'com.google.firebase:firebase-core:9.6.0'
compile 'com.google.firebase:firebase-crash:9.6.0'
compile 'com.google.android.gms:play-services:9.6.0'
compile 'com.google.android.gms:play-services-auth:9.6.0'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.afollestad.material-dialogs:core:0.9.0.1'
compile 'com.google.firebase:firebase-database:9.6.0'
compile 'com.google.firebase:firebase-auth:9.6.0'
compile 'com.firebaseui:firebase-ui-database:0.6.0'
}
apply plugin: 'com.google.gms.google-services'
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
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,
Please refer this document:
https://developers.google.com/android/guides/setup
for example if you need Google Account Login then just use :
com.google.android.gms:play-services-auth:9.6.1 not use compile 'com.google.android.gms:play-services:9.6.1'
just add this and try.
its works for me.
defaultConfig {
multiDexEnabled true
}
// multidex issues
compile 'com.android.support:multidex:1.0.0'
or
dexOptions {
javaMaxHeapSize "4g"
}
Have you add this in Application class
MultiDex.install(this);
Put this line in defaultConfig block
multiDexEnabled true
And add the following dependencies
compile 'com.android.support:multidex:1.0.0'
After this rebuild your project. Hopefully this should resolve your error.
Just remove unused libraries (or dependencies) from app's build.gradle file and again try to generate signed apk. It will work. :)
I have an android projct in Android Studio, was all previously working the last time I used it, however, I've upgraded Android Studio and now I am getting a weird problem.
In the error output in Android Studio I have the following:
Warning: Project MyApp: provided dependencies can only be jars. com.google.android.gms:play-services.6.5.87 is an Android Library
Warning: Project MyApp: provided dependencies can only be jars. com.MyCompany.MyLibrary:aar:1.0 is an Android Library.
Below is my build.gradle file.
apply plugin: 'android'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
//applicationId "com.MyCompany.MyApp"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
}
}
repositories {
mavenLocal()
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.MyCompany:CritiMon:1.0'
compile 'com.MyCompany:Library:1.1'
provided 'com.MyCompany:MyLibrary:1.0'
compile 'com.MyCompany:NavigationDrawerManager:2.1'
provided 'com.google.android.gms:play-services:+'
compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
}
Your provided dependencies can only be jars, your custom Android Libraries in your project should be compile at build time.
Change this:
provided 'com.MyCompany:MyLibrary:1.0'
provided 'com.google.android.gms:play-services:+'
to
compile 'com.MyCompany:MyLibrary:1.0'
compile 'com.google.android.gms:play-services:+'
I restore the Android Plugin Version from 1.1.0 to 1.0.0 and it work.
You can do it by the order:
Right-click your project.
Select `Open Module Settings`
Select `Project`
Change the `Android Plugin Version`