Error when implementing expansion panel in Android Studio - java

I want to make an expansion panel in my Android app but I tried many libraries and all of them can't sync in my Android Studio.
This is my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.github.florent37:expansionpanel:1.1.1'
}
apply plugin: 'com.google.gms.google-services'
and this is what happens after sync:
Error:Failed to resolve: com.android.support:appcompat-v7:26.1.0
Install Repository and sync projectOpen FileShow in Project Structure dialog

You should change
compile 'com.android.support:appcompat-v7:25.1.1'
to
compile 'com.android.support:appcompat-v7:27.1.1'
which is the latest available version found here
https://developer.android.com/topic/libraries/support-library/packages

Add this to your project level gradle inside allprojects -> repositories
Add maven { url "https://maven.google.com" }

Related

Android Studio 2.3.3: Failed to resolve: com.google.android.gms:play-services-ads:11.8.0 even with Maven

I'm working on one of my first apps on Android Studio and want to add advertisements to it using Admob. In my gradle: project I have Maven:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my app-level build.gradle dependencies as well
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile 'com.android.support:design:23.4.0'
testCompile 'junit:junit:4.12'
}
Even though I have Maven in repositories I still get the error message:
Failed to resolve: com.google.android.gms:play-services-ads:11.8.0
Shouldn't maven {url "https://maven.google.com"} be enough to import the Mobile Ads sdk?
You have to go
Tools>Android>SDK MANAGER>SDK TOOLS
and check for latest version(11.8.0) of Google Play services and Ok.
Finally , in build.gradle see that they have the same version.
enter image description here

LibGDX ClassNotFound on Android

I'm using libGDX for my game which shares some code with another project. I put this code in a .jar library which I have added in the root build.gradle.
Everything works fine on desktop, but when I launch the game on Android it crashes with a ClassNotFound exception. It can't find a class of my the library.
Can anyone help me out? I have no idea what is causing the problem.
Edit: changes to build.gradle:
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile fileTree(dir: '../libs', include: '*.jar')
}
}
You need to add the same fileTree dependency directly in the android module because the Android Gradle plugin currently can't handle transitive flat file dependencies.
project(":core") {
...
compile fileTree(dir: '../libs', include: '*.jar')
...
}
// And also
project(":android") {
...
compile fileTree(dir: '../libs', include: '*.jar')
...
}
Source.

After updating android studio and new sdk am getting the "Error:Execution failed for task ':app:processDebugGoogleServices'. How can I fix that?

Here is the error am getting when i try to build the app
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.
And these are the dependencies am using in my project
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile('com.mikepenz:materialdrawer:3.1.0#aar') {
transitive = true
}
compile 'com.github.navasmdc:MaterialDesign:1.5#aar'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.google.android.gms:play-services-ads:9.2.0'
compile 'com.google.android.gms:play-services-appindexing:9.2.0'
compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
compile 'com.quinny898.library.persistentsearch:library:1.1.0-SNAPSHOT'
compile 'com.github.nirhart:parallaxscroll:1.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.google.api-client:google-api-client-android:1.20.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.20.0' exclude module: 'httpclient'
compile 'com.google.apis:google-api-services-vision:v1-rev2-1.21.0'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'me.gujun.android.taggroup:library:1.4#aar'
}
After spending 2 days of searching in web i finally found a solution.
i put apply plugin: 'com.google.gms.google-services' at the end of my build.gradle file.
But i still don't understand why it didn't work when i write it on top.
May google knows :P

Failed to resolve: com.mcxiaoke.volley:library:1.0.19 in Android Studio

I am trying to update my library for the project by adding following dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:22.1.1"
compile 'com.mcxiaoke.volley:library:1.0.19'
}
Unfortunately, I am getting error as:
Error:(30, 13) Failed to resolve: com.mcxiaoke.volley:library:1.0.19
Error:(23, 17) Failed to resolve: junit:junit:4.12
The problem occurred because you used jar file that is deprecated and no longer being maintained.
Use this to include volley library:
compile 'com.android.volley:volley:1.0.0'
instead of compile 'com.mcxiaoke.volley:library:1.0.19' as volley dependency.
Keep tracking here: https://github.com/google/volley
for now it's:
compile 'com.android.volley:volley:1.1.0'
Add mavenCentral() at project level build gradle file `
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir}

Android .aar dependencies aren’t resolving in libraries

My goal is to distribute an .aar file that can be used by other developers in their projects. The problem I find is when i try integrate my .aar into other project, is i need specify all of the dependencies in their build.gradle file that I have already included in my .aar build.gradle.
My question it if possible only include my library as a dependency and somehow the libraries that my library depends on will get included in the other project.
For example, my library defines the following dependencies in its build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.altbeacon:android-beacon-library:2.3.5'
compile 'commons-codec:commons-codec:1.10'
}
I wrote a test app that uses my library and add like module in Android Studio interface
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile project(':myLibrary')
}
However, this does not work. I get java.lang.VerifyErrors at runtime. What ends up working is to include this in the app's build.gradle file:
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.altbeacon:android-beacon-library:2.3.5'
compile 'commons-codec:commons-codec:1.10'
compile project(':myLibrary')
}
Why do I need to include dependencies in both the .aar and the final application? What am I not understanding about how dependencies work? Why isn't the final application able to grab the .aar's dependencies from maven or jCenter at build time?

Categories

Resources