Facebook SDK Causes Warning in app Gradle File (Android Studio) - android

I am using the following dependency
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
Where the ${rootProject.ext.supportLibVersion} part refers to the value "25.3.1". Now the issue is that Gradle says that there is a conflict due to the existence of multiple versions of the same support library (specifically 25.0.0 and 25.3.1). I run the Gradle dependency tree task and viewed it. I finally found the conflict and it's caused by the Facebook SDK which uses the following:
com.android.support:cardview-v7:25.0.0
com.android.support:customtabs:25.0.0#aar
How to solve this conflict? I know the app is working and everything but a crash may happen in runtime. I also want to get rid of the warning in the Gradle file.

Related

compile 'com.android.support:multidex:1.0.1' happened wrong: all com android support libraries must use the exact same version

Today, I update my Android studio to 2.3, and I update gradle to 3.4.1. But when I build my project, an error occurred:
This is the error
So I add " buildToolsVersion '25.0.0' "
My project can build successful, but another error occurred. I can't solve it. I hope to get some help. Thank you!
This is the error
When I add compile 'com.prolificinteractive:material-calendarview:1.4.2', this error will occur.
This is my androidDependencies
This is probably an issue with Android Studio 2.3. There's a new inspection that checks if all dependencies of com.android.support use the same version number. However, multidex doesn't have a matching version number. You can disable the inspection via the red light bulb icon next to it as a work-around for now
it's an unnecessary warning for the support:multidex, add this:
//noinspection AndroidLintGradleCompatible
compile 'com.android.support:multidex:1.0.1'
I'm also using updated Studio. You should use each library with the same version in order to avoid the Manifest Merger issue. Like this.
// To Support Design, CardView and RecyclerView Library
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:palette-v7:25.2.0'
// To Support MultiDex
compile 'com.android.support:multidex:1.0.1'
Here you will notice that each library have the same version.
Change version of com.android.support:recyclerview-v7 and com.android.support:support-core-utils to 25.2.0 (last version of support library: https://developer.android.com/topic/libraries/support-library/revisions.html)

How to update the dependency libraries (for example Apache collection libraries) in Android Studio?

I know that in order to get the latest version of Android/Google libraries, I can always go to the Android SDK Manager and update the Android Support Repository / Google Repository.
How about to update the other dependency libraries, such as the "commons-net:commons-net:20030805.205232" from Apache collection libraries? Since it is able to add these libraries from a Module's dependencies, I assume there should be a way to update it within the Android Studio IDE, but so far all the solutions I found is to download the specific .jar and put in the libs directory.
Just curious if anyone know there is a way to update these libraries from within the Android Studio IDE like the Android/Google dependencies.
Android Studio & IntelliJ have a dependency setting window themselves. Though, it does not have a "update" feature as the SDK Manager does. Reason being: Updating a library can cause bugs, errors, or complete crashes in your app.
so far all the solutions I found is to download the specific .jar and put in the libs directory
Not sure where you read that... Remote Gradle dependencies are preferred in most cases.
such as the "commons-net:commons-net:20030805.205232"
Go find what you want in Maven Central, find the most recent version, click the "Gradle" tab, the copy that into your build.gradle section.
There is no automated process for this, as far as I know, though you should be able to auto-complete version numbers via the IDE while you type it out.
When you create a project under Android Studio, it generates for your gradle files which let you use dependencies. Gradle is like maven, you can find lot of documents on google.
Under "Project" tab -> Gradle Scripts -> build.gradle (Module app), you'll find something like this :
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.journeyapps:zxing-android-embedded:3.0.2#aar'
compile 'com.android.support:support-v13:23.4.0'
compile 'com.google.zxing:core:3.2.0'
compile 'com.android.support:support-v4:23.4.0'}
So you just have to put your dependencies and gradle will download them for you.
More here.

Should I move some dependencies to `runtime` in Gradle in Android Studio?

Using gradle-lint-plugin in Android Studio, it hints that
:lintGradle
This project contains lint violations. A complete listing of the
violations follows. Because none were serious, the build's overall
status was unaffected.
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:43 compile 'com.android.support:appcompat-v7:24.1.0'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:44 compile 'com.android.support:design:24.1.0'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:45 compile 'com.android.support:cardview-v7:24.1.0'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:52 compile
'com.github.gigamole.arcprogressstackview:library:+'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:53 compile 'com.github.dexafree:materiallist:3.2.1'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:54 compile 'com.android.volley:volley:1.0.0'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:55 compile 'com.cocosw:bottomsheet:1.+#aar'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:57 compile 'com.android.support:support-v4:+'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:58 compile 'com.github.shem8:material-login:1.4.0'
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:64
compile('com.github.ozodrukh:CircularReveal:1.3.1#aar') {
transitive = true; }
this dependency should be moved to the runtime configuration since it
has no classes warning unused-dependency
app/build.gradle:74 compile 'com.github.rey5137:material:1.2.4'
? app/build.gradle: 11 problems (0 errors, 11 warnings)
To apply fixes automatically, run fixGradleLint, review, and commit
the changes.
BUILD SUCCESSFUL
Should I take the advice? If those dependencies should be in runtime, Why does every dependencies wiki/doc don't say that and insist telling us to put dependencies in compile?
Edit: I try to take the advice, in other words, change the keyword compile to runtime, like runtime 'com.android.support:appcompat-v7:24.1.0'. However, Android Studio hints that
Error:Could not find method runtime() for arguments
[com.android.support:appcompat-v7:24.1.0] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK
Manager. Open Android SDK Manager
So what's the problem?
I believe apk is android for runtime, e.g.:
apk 'com.android.support:appcompat-v7:24.1.0'
Some say package
https://stackoverflow.com/a/28473873/360211
Maybe both work, maybe there is no difference, maybe there is. I don't know as very ungoogleable terms.
You should put dependencies that you need for compilation in compile, this includes classes you use directly in your sources.
You should put dependencies that you don't need for compilation, but need at runtime in runtime, those are not available on the compile classpath, but they will be available at execution.

How to resolve Theme.AppCompat.Light error

I am facing a issue after run existing android studio project. Please check error below and let me know how to resolve that.
Error:(54) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
Thanks in advance
Try to use accroding gradle plugin. I've got the problem with plugin 2.3-beta1 and Studio 2.2.3, when changed to plugin 2.2.3 - everything worked like a charm
Please change compileSdkVersion and buildToolsVersion in your gradle file according to your android studio existing running project.
Our compile SDK version must match the support library's major
version.
If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK.
Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.
You can either change it manually in your build.gradle, or you can use
the GUI by opening up the project properties and going to the
"dependencies" tab.
Or Press Ctrl + Shift + Alt + S to get to the project structure page. Go to the properties tab and change version to 23.0.0 or whatever latest in the build tool area and rebuild your project.
If that doesn't work, go to gradle:app and then
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
Edit version as shown above and sync gradle.
Ran into same issue as OP, March 2017 Android Studio 2.3.
My build was working fine for months, and this issue came up right after adding a new line to gradle build file. Ultimately making some changes in Gradle and re-sync'ing fixed the issue, but my Gradle ended up being exactly the same as when the issue first came up, strangely.
My original Gradle build dependencies:
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:gridlayout-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.google.android.gms:play-services-location:10.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.0'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.4'
Then, I simply added a new line:
compile 'org.scribe:scribe:1.3.5'
This is when the issue appeared, same as OP.
I saw red errors in my styles.xml and wondered "wtf?".
Cleaning and re-building had no affect.
Going back to the Gradle build file, I commented-out that new line. ISSUE RESOLVED! So obviously there was something going on.
For fun, I put that line, uncommented, at the top of this compile list. NO ISSUE!
For fun yet again, I put that line back again to the bottom of the list (like how originally added it). NO ISSUE.... weird!
How Gradle sync'ing responds doesn't seem to be 100% consistent. I did no other changes to my project. All I can say is try toggling and re-ordering things in the compile list.

Unable to resolve imports from external dependencies in Android Studio 2.0 Preview 5 + Preview 6

After upgrading from the last Android Studio 2.0 preview to Preview 5 I'm having trouble with the imports from the android.support.wearable package.
Both the main app and Wear app builds and run just fine, but the editor in Android Studio complains that it can't resolve the these imports
import android.support.wearable.activity.WearableActivity;
import android.support.wearable.view.CircledImageView;
import android.support.wearable.view.WearableListView;
In the Wear module's build.gradle I have the following dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':common')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.google.android.support:wearable:1.3.0'
provided 'com.google.android.wearable:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
}
As I understand from http://developer.android.com/training/wearables/apps/always-on.html#EnableAmbient this should work when using the provided statement. And it has worked well until the Android Studio upgrade. Am I missing something?
Update:
This isn't just a problem with the Wear library, it's general for what seems to be any external dependency. (Topic originally was Unable to resolve package android.support.wearable in Android Studio 2.0 Preview 5.)
It seems like the problem can occur at any time, but in practice it happens mostly whenever I do lotsa changes in a class (maybe changes to the imports?). Just now it suddenly was unable to resolve the imports of Play Services and Facebook ads (while still working for other dependencies).
I accidentally found a workaround of the problem: If I open and build the project in Android Studio 1.5 which I also have installed, all the imports are fixed. Going back to Android Studio 2.0 I can continue programming without the imports becoming unresolvable for a long while.
For anyone googling the problem, the error message in Android Studio is the usual Cannot resolve symbol '[package]'.
I had this problem even before with AS 1.5, the easiest way for me to fix it was to use the Terminal inside Android Studio and execute:
./gradlew assembleDebug
This will work if you're not using flavors if not just use the name of the flavor, for e.g:
./gradlew assembleFlavorNameDebug
that should work too as a workaround without leaving your current instance of AS, and then the compiler recognizes your imports if everything is setup properly.
For more references please look: http://tools.android.com/build/gradleplugin
https://stackoverflow.com/a/21307568/799162

Categories

Resources