Volley and symbol not found: AndroidHttpClient - android

I'm working on Android Studio on some one else's code that uses Volley.
I updated inside gradle to latest compileSdkVersion, buildToolsVersion (24) and targetSdkVersion.
Inside gradle configuration, volley was included in this way:
compile 'com.mcxiaoke.volley:library:1.+'
I migrated to:
compile 'com.android.volley:volley:1.+'
I get some nasty 400 error, that should mean that the connection is done but it is for some reason wrong... then I found that inside Volley.java there's an error that I was not aware of, because it simply wasn't shown and the app was correctly compiled and run:
import android.net.http.AndroidHttpClient;
is in red and so is the subsequent call to a method in
AndroidHttpClient
(that fails with "symbol not found").
Now I have two questions:
how is it possible that I compile and run the application if there is an error in a library? I'm missing this.
how can I fix this, without moving to other network libraries?
Update:
to clarify, compiling to API 22 removes the error. compiling to API 24 creates this error that appears directly inside Volley's source. I would like to compile to API 24 without Volley, is it possible?

Related

Android: library project with play-services-auth results in NoClassDefFoundError

(This is basically the same question as in Android: library project with Retrofit results in NoClassDefFoundError but for play-services-auth).
I'm trying to build an android library project which uses play-services-auth to access SmartLock for Passwords.
It seems to be working as long as I use api instead of implementation on my gradle-dependency for com.google.android.gms:play-services-auth. It seems that this is the only dependency needing this (all others can used with implementation).
When using implementation here as well, the calling app will crash with NoClassDefFoundError:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/GoogleApiClient$Builder;
I'm using consumerProguardFiles with a bunch of proguard-rule-files (e.g. one for okhttp3, retrofit2 etc. from this repo). All this will then be packed into an AAR, so rules from the dependencies should be added as well.
It seems that I'm missing a proguard-rule for play-services-auth. Can somebody post the rules needed to use com.google.android.gms:play-services-auth in a library project?

Android Databinding build fail after Gradle plugin update with migration to annotationProcessor

To support Instant Run in my version of Android Studio, I needed to upgrade my Gradle plugin from version 2.2.3 to 2.3.3
I'm aware I'm supposed to migrate to annoationProcessor and I believe I've followed that guide correctly
after doing so, the Android DataBinding code generation fails
The migration guide linked earlier states that all I need is to
Make sure you are on the Android Gradle 2.2 plugin or newer
Remove the android-apt plugin from your build scripts
Change all apt, androidTestApt and testApt dependencies to their new format
This should be all that's needed to successfully build the project. Yet it doesn't build.
Build output
Gradle build finished with 101 error(s) and 23 warning(s) in 12s 481ms
All of the errors follow the same pattern:
C:\Users...\FooAdapter.java
error: package com.example.app.databinding does not exist
error: cannot find symbol class ItemFooBinding
An interesting message can be found in the build console:
Warning:The following options were not recognized by any processor: '[android.databinding.minApi, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir, android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.isTestVariant]'
I would like to point out that...
I presume I don't have an error in some XML file, binding expression or a naming issue. The same set of sources and XML build when I switch back to the Git branch with the old gradle plugin version (and all of the other source files up-to-date)
I did increase the limit of output build errors as discussed here, although this doesn't seem to be relevant right now, since as you can see, I currently have "only" 101 errors. :)
Additional info
The following diffs show how I've modified my gradle files:
build.gradle DiffChecker link
app/build.gradle DiffChecker link
Also, as a quick overview, here is the list of some of the "more interesting" plugins & libraries used by the project:
Kotlin
Android DataBinding
Realm
Retrofit
Dagger
ButterKnife (I know...)
Multidex Support Library
Does anyone have a clue what could be the issue? Any help or idea will be greatly apprecitated!
I had exactly the same warning. This line in gradle solved the issue:
kapt "com.android.databinding:compiler:3.0.1"
Hopefully, it will help somebody
Update:
3.0.1 is Android Plugin Version.
When you see innumerable build errors mentioning databinding as in this case, the problem usually lies somewhere else. Databinding just gets stopped in its tracks by unrelated build problems and complains exceedingly loudly. The only way to deal with it is to locate the build errors that are not tied to databinding. Once they are fixed, databinding can do its thing again and be silent. Unfortunately you often have to repeat this approach several times until you have found all non-databinding issues. It's an arduous task for sure, but unfortunately there is nothing else you can do until Google manages to provide a saner build environment.
This is the reason why you are advised to increase the build error limit beyond 100 - you would not see the actual errors causing your problems, because they commonly do not show up early in the list.
I will chance a guess - Dagger 2 is a common source of triggering this problem, which could be related to your annotationProcessor change; so look out for Dagger errors. But your issues could be caused by other things, like other annotation processors as you mentioned - you wouldn't know for sure until you diligently dig through your build errors.
It seems it all comes down to my project using Kotlin. Actually we have it mixed: some classes use plain old Java while others are written in Kotlin. An incomplete migration. :)
I assume that without Kotlin, replacing apt with annotationProcessor would be enough and I wouldn't have ran into this issue at all.
Solution
Annotations need to be processed by both annotationProcessor and kapt, which seems to be Kotlin's own annotation processor.
For each Gradle dependency that uses annotations, you should have both of the following in your app-level build.gradle:
annotationProcessor 'com.example.my.library:x.y.z
kapt 'com.example.my.library:x.y.z

How to use 3rd party libraries which are incompatible with buildToolsVersion "25.0.0"?

I am using 3rd party library on a new android project but, it shows me the error below but, if I remove the usage of this library then my project runs fine.
The error image
android sdk 25 error
The library I want to use is compile 'com.github.pro100svitlo:lockpattern:0.9.3'
Is there any way I can get rid of this error and work with this library?

Android Studio: android.support.v7.widget.RecyclerView Error

I am currently having this error. I am using API 21 and I know some folks here suggested to upgrade it to API 22 base on previous questions but the tutorial(Slidenerd of Youtube) I am following is using API 21 and did not encountered any errors like this. Weird thing also because my RecyclerView in emulator is just working fine as expected in his tutorial and I don't why this error keeps popping up. Thanks !
It is not an error. Because the constructor is getting called while viewing the layout. Normally there are some operations which are going to be executed. To avoid this there is View.isInEditMode().
Normally you would use it like this
public Constructor(){
if(View.isInEditMode())
return;
}
If I understand your question correctly you are talking about the message the preview window of your layout is giving you?
You are probably using a version of recycler view that is newer than your compile version.
In you build.gradle file where you have added recyclerview to your dependencies you can try downgrading the version you are using
Change compile 'com.android.support:recyclerview-v7:22.2.1'
to compile 'com.android.support:recyclerview-v7:21.0.3' (or change to a 21.x.x version that suits your needs

Cannot resolves symbol packetInterceptor

I am trying to run the XMPP-based App Server based on Smack library
I'v added the required dependencies based on smack 4.1.0. I have problem with one Import:
import org.jivesoftware.smack.PacketInterceptor;
I experience the error message
Cannot resolves symbol PacketInterceptor
How do I resolve this?
If you are using gradle, use following dependencies
compile "org.igniterealtime.smack:smack-java7:4.0.1"
compile "org.igniterealtime.smack:smack-extensions:4.0.6"
compile "org.igniterealtime.smack:smack-tcp:4.0.6"
Or download the jar for the smack 4.0.6
Apparently, in the latest 4.1.0-Beta version they made some change to API but lack of enough clear documents.

Categories

Resources