I am trying to build the project which has a large dependency graph and uses dagger 2.
I use following dependencies
implementation 'com.google.dagger:dagger:2.11'
androidTestImplementation 'com.google.dagger:dagger:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
I am not able to build the app because it shows 50 errors like
cannot find symbol class DaggerAddressComponent
cannot find symbol class DaggerAddToCartActivityComponent
cannot find symbol class DaggerPaymentFragmentComponent
cannot find symbol variable GlideApp
...More 50 like this
All the DaggerComponent are not found and I also don't see any dagger classes created in generatedJava Folder.
I know this may happen due to syntax error, but I checked all the modules and don't see any.
Does Someone know how to fix this? Or guide me on how to track down any mistakes in my modules/components. gradle log does not show anything related to dagger so how can we know where is the mistake?
After whole day and going through every line of my code, I found that I have one duplicate method in my view interface, which happened during merge. Removed that and all the things were good.
It is strange how Android studio shows all the class not found error and does't show that error. I know it is a silly mistake but it is confusing to find the real error if you don't see that error in logs.
Related
In my project I had this dependency:
dependency org="org.apache.cxf" name="cxf-bundle" rev="2.7.16"
I updated it to:
dependency org="org.apache.cxf" name="cxf-bundle" rev="3.0.0-milestone2"
After doing that and recompiling I now get a Error:
Could not find or load main class
If I go back to the previous revision all is well again.
How can I find out what the issue is in the updated bundle that would be causing me to get this error? I'm assuming here that it's either a different jar that I need that was removed from the newer bundle or there is an updated jar that is affecting this but I am at a loss to figure out which.
Any tips would be appreciated.
Looks like I found out what was going on. I was trying to also remove unused jars and that would cause the issue.
I got side tracked because the error was telling me it couldn't fine my class. If it had given a different class name then it would have been easier to figure out.
This question already has an answer here:
Migrate resource files to Androidx
(1 answer)
Closed 3 years ago.
I've have recently migrated my app to AndroidX, blindly without knowing the ins and outs. As a result every time I run the project, it gives me a load of errors.
I have updated all my Gradle Dependencies and targetSDK to the most recent version code. I have also added the following to gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
But this has still made no difference.
Some of the following are examples of errors I am getting:
error: package android.support.annotation does not exist
error: package android.support.v7.widget does not exist
error: package RecyclerView does not exist
error: cannot find symbol class FragmentActivity
error: cannot find symbol class CardView
error: cannot find symbol class FragmentPagerAdapter
error: cannot find symbol class DialogFragment
I would just like to know I can get rid of these errors, as it is stopping me from running the project on my mobile device?
Here you can find the full class mapping.
In your case you have to change the imports:
error: package android.support.annotation does not exist
error: package android.support.v7.widget does not exist
Packages:
package androidx.annotation.*;
package androidx.appcompat.widget.*;
Classes:
android.support.v4.app.FragmentActivity androidx.fragment.app.FragmentActivity
android.support.v7.widget.CardView androidx.cardview.widget.CardView
android.support.v4.app.FragmentPagerAdapter androidx.fragment.app.FragmentPagerAdapter
android.support.v7.app.AppCompatDialogFragment androidx.appcompat.app.AppCompatDialogFragment
android.support.v7.widget.RecyclerView androidx.recyclerview.widget.RecyclerView
You seem to have everything set up correctly in your gradle file. The problem is that there are missing packages that have not yet been converted/migrated to AndroidX. Here's a little trick you can do:
Go to your app.gradle file and right-click anywhere.
Select Refactor on the menu that pops up.
In the sub-menu, select Migrate to AndroidX
Sit back and let Android studio migrate all your files.
To learn more, check this out.
I hope this helps. Merry coding!
In the Android Studio menu go to Refactor and select Migrate to AndroidX.
Rest the android studio will automatically do.
Other than this if you still find the error then you will have to manual perform certain task.
In the layout find all the old one and replace it like
android.support.v7.widget.CardView
with
androidx.cardview.widget.CardView
you will find the mapping related information here https://developer.android.com/jetpack/androidx/migrate/class-mappings
just find the old text by using Ctr+F and copy the replacement text
In the app build
implementation 'com.android.support:cardview-v7:28.0.0'
with
implementation 'androidx.cardview:cardview:1.0.0'
you will find mapping related information here https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
I am working on a project where I am trying to implement ExoPlayer to replace a VideoView. My issue is that I am getting this error: cannot find symbol class ProgressiveMediaSource
I have seen Why can't I locate ProgressiveMediaSource? and note that it is mentioned that ProgressiveMediaPlayer was added in ExoPlayer 2.10.0 - I am using 2.10.1 so version shouldn't be an issue. The other condition that was mentioned was having the Android project upgraded to AndroidX. I believe that I am only using AndroidX unless one of my dependencies is importing some support libraries (com.android.support).
The compiler throws an error on import:
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
If providing my gradle build script would help, let me know.
Error was due to human transcription error. I had typed progessive instead of progressive and never noticed until much later 😫
Lesson: if a symbol can't be found, make sure you spelled it correctly.
I'm trying to set up the PubNub jar as a library in my Android Studio project. The project is something I am porting over from another computer, so I'm mostly copying things in.
It appears between then and now that I now have to configure the AnnotationProcessor of this jar, but I'm really not sure what that requires, nor have I been able to find an example that fits my issue.
When I try to compile my project, I am left with this message:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:javaPreCompileDebug'.
Annotation processors must be explicitly declared now.
The following dependencies on the compile classpath are found to contain annotation processor.
Please add them to the annotationProcessor configuration- pubnub-gson-4.19.0-all.jar (pubnub-gson-4.19.0-all.jar).
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.
Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error- message.html for more details.
I'm really not sure at all what this is telling me to do, and the examples I can find of annotationprocessor on the internet (none for PubNub) all are pointing to packages and classes, which I don't see what I am suppose to do with.
Can someone lead me down the correct path?
I apologize for the formatting of the error, but the site wouldn't let me submit it in blockquotes because it was "improperly formatted code."
Try to add this line in your dependencies{} block:
annotationProcessor files('libs/pubnub-gson-4.19.0-all.jar')
(along with the implementation files('libs/pubnub-gson-4.19.0-all.jar'))
It works in my case.
I am trying to create a line graph. I found a tutorial from the following site which I have been following:
https://github.com/PhilJay/MPAndroidChart/wiki/Setting-Data
The problem I am having is with this line of code:
List<ILineDataSet> dataSets = new ArrayList<>();
Android studio does not seem to recognize the type "ILineDataSet" and as a result is preventing me from proceeding any further in completing this task.
It has offered solutions to resolve it, which are:
Create Class
Create Enum
Create Inner Class
Create Interface
All of which I do not think will solve the issue as I assume the library has already configured this but for some reason its not being picked up by android studio.
Could someone direct me as to how I can resolve this issue?
Thanks!
I'm so stupid.
Library wasnt updated.
Please ignore this
I was going to ask if you added:
dependencies {
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
}
To your gradle.build