android build error: can't find symbol class IntDef - java

Using Android Studio to build the android version of a react native app. I just received
'error: cannot find symbol class IntDef'
It's used in the following code:
#IntDef(flag = true, value = { Information.BATTERY, Information.RSSI, Information.API_VERSION, Information.LED,
Information.APPLICATION_VERSION })
the bottom of my dependencies block looks like this:
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
Do I need to make an import at the top of this file..or is do I need to add to the build.gradle such as implementation 'androidx.appcompat:appcompat:1.0.0'
inside the dependencies block?
I had the same issues except it was with ArrayMap, this was fixed by adding
compile "com.android.support:support-core-utils:24.2.0"
in the dependencies

You probably will have to include the following in your build.gradle file:
dependencies {
implementation 'com.android.support:support-annotations:28.0.0'
}
And the import statement in your class would be such :
import android.support.annotation.IntDef;

Related

Hilt :- Not able to use the #AndroidEntryPoint in the AppCompatActivity getting DefaultV iewModelFactories exceptions?

I want to use the Hilt in my project for getting the helper class object as the common for my activity. I have tried the below lines of code for it
Manifest file entry
<application
android:name=".application.AppController"
android:allowBackup="false"
My AppController class
#HiltAndroidApp
public class AppController extends Application implements Configuration.Provider {
}
Please check my gradles file for it
implementation "androidx.activity:activity-ktx:1.2.3"
implementation 'androidx.fragment:fragment-ktx:1.3.4'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
implementation 'com.google.dagger:hilt-android:2.36'
kapt 'androidx.hilt:hilt-compiler:1.0.0'
kapt 'com.google.dagger:hilt-android-compiler:2.31.2-alpha'
Please check my classPath entry below
classpath "com.google.dagger:hilt-android-gradle-plugin:2.36"
Now please check my NVModule Module class in which i have used the Hilt
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
#Module
#InstallIn(SingletonComponent::class)
class NVModule {
#Provides
fun provideDeviceDiagnosticHelper(): DeviceDiagnosticHelper{
return DeviceDiagnosticHelper()
}
}
Now please check the Activity class in which i have injected the Hilt object
#AndroidEntryPoint
public class AutomaticTestActivity extends AppCompatActivity {
private AutomaticTestPresenter automaticTestPresenter;
private AutomaticTestView automaticTestView;
ActivityDeviceDiagnosticBinding mBinding;
#Inject
DeviceDiagnosticHelper deviceDiagnosticHelper;
}
But I am getting the following exception while Running the app please check it once
Exception:-
/home/..../com/my/app/activity/Hilt_AutomaticTestActivity.java:70: error: method getActivityFactory in class DefaultViewModelFactories cannot be applied to given types;
return DefaultViewModelFactories.getActivityFactory(this);
^
required: ComponentActivity,Factory
found: Hilt_AutomaticTestActivity
reason: actual and formal argument lists differ in length
Please help me to short of from this problem
Seems to be version mismatch. Use following versions:
// hilt
implementation 'com.google.dagger:hilt-android:2.36'
kapt 'com.google.dagger:hilt-android-compiler:2.36'
kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.36'
kaptTest 'com.google.dagger:hilt-android-compiler:2.36'
// implementation "androidx.hilt:hilt-navigation:1.0.0"
// implementation "androidx.hilt:hilt-navigation-fragment:1.0.0"
kapt 'androidx.hilt:hilt-compiler:1.0.0'
And
apply plugin: 'dagger.hilt.android.plugin'
And
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.36'
version of dependency for project level and app level must be same.
like :
classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
and
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-android-compiler:2.38.1"
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-android-compiler:2.38.1"
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
kapt 'androidx.hilt:hilt-compiler:1.0.0'
worked for me

I have a Error to add #Entity data annotation to class android for room database

My friends from the Android site I copied the dependencies related to room in Gradle but I can not add Dataantotaion related to Entity to the class and after add #Entity it has Error "Canot resolve symbol 'Entity'
I use Java android
Change
annotationProcessor "android.arch.persistence.room:compiler:$Versionroom"
To
implementation "android.arch.persistence.room:compiler:$Versionroom"
And add
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
hope this help you fix the symbol resolving problem.
you have to add room dependencies and annotationProcessor dependencies for it Try is :
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

How to resolve gradle dependency conflicts on library root dependency?

In my project I have two dependencies with okio as a transitive dependency conflict. In theory, gradle should solve it by choosing the highest version, but that didn't work.
I have been trying everything, since exclude until force the version from okio lib, but nothing works. Looking on external libraries path, I realized that one of the dependencies contains the okio as a path of the dependency, and I believe that this is the problem. But how can I solve this?
This is a simple gradle example with my two dependencies. Commented lines are my failed attempts to solve the problem:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
}
repositories {
mavenCentral()
}
//configurations.all {
// resolutionStrategy.force('com.squareup.okio:okio:2.4.3')
//}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
// -> dependency one
implementation "com.squareup.retrofit2:retrofit:2.7.2"
// implementation ("com.squareup.retrofit2:retrofit:2.7.2"){
// exclude group: 'com.squareup.okio'
// }
// -> dependency two
implementation "com.eternitywall:java-opentimestamps:1.18"
// implementation ("com.eternitywall:java-opentimestamps:1.18") {
// exclude group: 'com.squareup.okio'
// }
// implementation "com.squareup.okio:okio:2.4.3"
// implementation "com.squareup.okio:okio"
// constraints {
// implementation("com.squareup.okio:okio:2.4.3") {
// because 'transitive version conflict'
// }
// }
}
To get the error, just have a Main.kt file with the code:
import okhttp3.OkHttpClient
fun main(args: Array<String>) {
OkHttpClient.Builder()
}
And the error obtained is:
Exception in thread "main" java.lang.NoSuchMethodError: 'boolean okio.ByteString.startsWith(okio.ByteString)'
at okio.Options.of(Options.java:64)
at okhttp3.internal.Util.<clinit>(Util.java:73)
at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:124)
at okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.java:449)
at MainKt.main(Main.kt:4)
And finally, this is the library root that I mentioned from dependence with the included okio
I will be very grateful if you can help me.
Thanks in advance!!
Well, it seems that the only solution is to separate the app into modules, placing each dependency in a different module. Even though I was reluctant it was the only way I found.

Unable to add dependency: Failed to resolve: androidx.lifecycle:lifecycle-extensions:2.2.0-rc2

I am trying to add few dependencies to my Android project but I'm still getting some weird errors.
I am trying to add recommended dependencies which I've found on CodeLabs but it steel does not allow me to sync my gradle files successfully.
The error that is keep showing up is the following: ERROR: Failed to resolve: androidx.lifecycle:lifecycle-extensions:2.2.0-rc2
Code: inside gradle module
// Room components
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
// UI
implementation "com.google.android.material:material:$rootProject.materialVersion"
// Testing
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
Text inside gradle project:
ext {
roomVersion = '2.2.1'
archLifecycleVersion = '2.2.0-rc2'
coreTestingVersion = '2.1.0'
materialVersion = '1.0.0'
}
This is also one error that I am getting sometimes, it appears randomly...
ERROR: Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.1.0] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:11:5-28:19 to override.
The error log literally says there is no androidx.lifecycle:lifecycle-extensions version 2.2.0-rc2.
Change archLifecycleVersion = '2.2.0-rc2' to archLifecycleVersion = '2.2.0-rc02' to fix that error.
The APIs in lifecycle-extensions have been deprecated. Instead, add dependencies for the specific Lifecycle artifacts you need.
dependencies {
def lifecycle_version = "2.2.0"
def arch_version = "2.1.0"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// Lifecycles only (without ViewModel or LiveData)
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
// Saved state module for ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
// Annotation processor
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
// optional - helpers for implementing LifecycleOwner in a Service
implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"
// optional - ProcessLifecycleOwner provides a lifecycle for the whole application process
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
// optional - ReactiveStreams support for LiveData
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
// optional - Test helpers for LiveData
testImplementation "androidx.arch.core:core-testing:$arch_version"
}
From this source

GlideApp cannot be found

error: cannot find symbol variable GlideApp
This is the error I have been getting.
I'm using Android studio 3.3.1 and imported these modules for glide.
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
GlideApp.with(this /* context */)
.load(storageReference)
.into(MainImage);
If GlideAPP can't be generated
annotationProcessor com.github.bumptech.glide:compiler:4.9.0
Must be with ‘AppGlideModule Implementation class’ In the same module
To use generated API in Glide you need to create a class and extend AppGlideModule and use #GlideModule annotation, for example:
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
#GlideModule
public final class MyAppGlideModule extends AppGlideModule {
}
After this rebuild and you should be able to use GlideApp for more information visit:
http://bumptech.github.io/glide/doc/generatedapi.html
def glide_version = "4.12.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
Then Sync it will work.
Working Screenshot
Optional: You can also do this. Build -> Make Module
If you use Kotlin, try to use kapt instead of annotationProcessor.
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"

Categories

Resources