Cant find library on import statement in Java Class - Android - java

I'm very new in Android development, and I'm trying to import a library from Github via Gradle. I added a statement in the 'dependencies' section:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
}
But I cannot find the library in my Java class when I try to import it:
import com.squareup...; //Nothing I put here works.
public class MainActivity extends AppCompatActivity {
}
Can somebody point out what I am missing?
Thanks.

Related

How to add Recycler view in android studio

I am not able to use the RecyclerVeiw class even after adding dependencies in build.gradle(Module:app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
No need to add any special dependency
Just update android studio and use it
Even though if you want to make it work through adding dependencies add this
//in xml add this
<androidx.recyclerview.widget.RecyclerView>
// in class add this
import androidx.recyclerview.widget.RecyclerView;
no need to add any dependency
//in xml
<androidx.recyclerview.widget.RecyclerView>
// in class
import androidx.recyclerview.widget.RecyclerView;

package androidx.appcompat.widget does not exist Android Studio

I have created a custom Class which extends ImageView. It was working perfectly fine until AndroidX shows up.
Here, the java code
import android.content.Context;
import android.graphics.BitmapFactory;
import android.util.Base64;
import android.widget.RelativeLayout;
import androidx.appcompat.widget.AppCompatImageView;
public class CloseView extends AppCompatImageView {
public CloseView(Context context) {
super(context);
init();
}
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Android shows 2 errors for this file
error: cannot find symbol class AppCompatImageView
error: package androidx.appcompat.widget does not exist
Has anyone able to fix this issue?
You should completely migrate to AndroidX to use its classes
Enable AndroidX in Gradle settings:
android.useAndroidX=true
android.enableJetifier=true
Replace dependencies
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
instead of
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
See: https://developer.android.com/jetpack/androidx/migrate
Edit:
AndroidX is the newest replacement to all the previous numbered support libraries. Read more about it here before you start using it.

cannot resolve symbol for v4 media and app classes

I'm trying to import the following classes for my media player, but my app does not recognize them:
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaControllerCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v7.app.NotificationCompat;
I've tried as others suggested (File->Invalidate Caches/restart), but the error remains.
gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
implementation 'com.android.support:cardview-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.7', changing: true
}
Add this dependencies to your gradle ;
com.android.support:support-v4:YOUR_VERSION
in long way ;
Project Structure --> Dependencies --> Click Plus sign -> Go to
"Library dependency"
Select which support library "support-v4
(com.android.support:support-v4:YOUR_VERSION)"
Be sure about Android Support Library has been added to your
dependencies.
Rebuild and work it.
Just Add Dependencies in our Gradle File
dependencies {
......
implementation 'com.android.support:support-v4:VERSION'
.....
}
Ex
dependencies {
......
implementation 'com.android.support:support-v4:27.0.1'
.....
}
For android x based projects, add this
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

Could not find class 'com.google.android.chimera.Activity', referenced from method mu.b

When I start app and click button, I'm getting an error.I want make take photo and detect face after Automatically add on glass.
Could not find class 'com.google.android.chimera.Activity', referenced from method mu.b
Also
Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappin‌
Here is my gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services-vision:10.2.1'
}
this seem to be a proguard issue.
Try adding to your proguard-project.txt:
keep class com.google.android.chimera.** { *; }
dontwarn com.google.android.chimera.**

how to import Universal tween engine in IntelliJ with lib gdx

okay.. I'm trying to create a splash screen for my mobile game. im using lib gdx library to create my game. i have a problem with importing the universal tween engine for my sprite splash. what should I do.
I've downloaded the universal tween engine and extracted it in the "libs" folder in the ios, android, core, and root of my project.. and i copied and paste these lines for each dependencies:
project(":core") {
fileTree(dir: 'D:/game/core/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/core/libs', include: 'tween-engine-api->sources.jar')
project(":desktop") {
compile fileTree(dir: 'D:/game/desktop/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/desktop/libs', include: 'tween-engine-api->sources.jar')
project(":ios") {
compile fileTree(dir: 'D:/game/ios/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/ios/libs', include: 'tween-engine-api->sources.jar')
project(":android") {
compile fileTree(dir: 'D:/game/android/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/android/libs', include: 'tween-engine-api->sources.jar')
the code in my Spite accessor class :
package com.game.test;
import aurelienribon.tweenengine.TweenAccessor;
public class SpriteAccessor implements TweenAccessor{
}
the error:
Error:(3, 33) java: package aurelienribon.tweenengine does not exist
Error:(5, 40) java: cannot find symbol symbol: class TweenAccessor
P.S.
Im following a video tutorial by dermetfan and I also put in th terminal these lines:
gradlew --refresh-dependencies
LibGdx uses gradle for dependency management.
You can inject dependency from repository.
add these lines in your core module of root build.gradle file.
repositories {
maven { url "https://jitpack.io" }
}
compile 'com.github.arcnor:universal-tween-engine:6.3.4'
compile 'com.github.arcnor:universal-tween-engine:6.3.4:sources'

Categories

Resources