Information:Gradle tasks [:app:assembleDebug] Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationExceptio
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion " 21.1.2"
defaultConfig {
applicationId "com.flikster.flikster"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "2g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.makeramen:roundedimageview:2.2.1'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.pnikosis:materialish-progress:1.5'
}
Add below line to application tag in AndroidManifest.xml if you don't have any class which extends Application class
android:name="android.support.multidex.MultiDexApplication"
or add below to onCreate() method if you have any class which extends Application class
MultiDex.install(getBaseContext());
Create an Application Class
Initialize it MultiDex in onCreate()
public class MyApplication extends Application {
private static MyApplication applicationContext;
public static boolean isNotificationProcessing = false;
public MyApplication() {
applicationContext = this;
}
#Override
public void onCreate() {
super.onCreate();
MultiDex.install(getBaseContext());
}
}
Rebuild and run again
Related
I have Gradle build like this
plugins {
id 'org.springframework.boot' version '2.4.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'test.build'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.springframework.session:spring-session-core'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
and here my application
package test.build.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
When I build the project, I see there is an error like in this picture:
What is the issue? Is there any error in my Gradle build file?
Looks like you have a missing dependency. Try adding the following dependency:
implementation 'org.springframework.boot:spring-boot-starter'
I have Gradle build like this
plugins {
id 'org.springframework.boot' version '2.4.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'test.build'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.springframework.session:spring-session-core'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
and here my application
package test.build.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
When I build the project, I see there is an error like in this picture:
What is the issue? Is there any error in my Gradle build file?
Looks like you have a missing dependency. Try adding the following dependency:
implementation 'org.springframework.boot:spring-boot-starter'
world of Android. While I try to run the app it log return me this error
Error:(51, 26) error: cannot access LifecycleObserver class file for android.arch.lifecycle.LifecycleObserver not found
I'm using this library for manage the YouTube player
public class DirettaActivity extends AppCompatActivity{
private YouTubePlayerView youTubePlayerView;
private FullScreenManager fullScreenManager;
private #Nullable YouTubePlayer initializedYouTubePlayer;
private String videoIds = "6JYIGclVQdw";
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diretta);
fullScreenManager = new FullScreenManager(this);
youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtube_player_view);
this.getLifecycle().addObserver(youTubePlayerView); //this line give me error! "Cannot resolve getLifecycle"
youTubePlayerView.initialize(initializedYouTubePlayer -> {
initializedYouTubePlayer.addListener(new AbstractYouTubePlayerListener() {
#Override
public void onReady() {
DirettaActivity.this.initializedYouTubePlayer = initializedYouTubePlayer;
initializedYouTubePlayer.loadVideo(videoIds, 0);
}
});
addFullScreenListenerToPlayer(initializedYouTubePlayer);
}, true);
} //other code...
Here my build.gradle of the app
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.16.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.yalantis:ucrop:2.2.1'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile "android.arch.lifecycle:runtime:1.0.0-alpha2"
compile "android.arch.lifecycle:extensions:1.0.0-alpha2"
implementation "android.arch.lifecycle:livedata:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha2"
compile 'com.writingminds:FFmpegAndroid:0.3.2'
compile 'com.google.apis:google-api-services-youtube:v3-rev186-1.23.0'
compile files('libs/YouTubeAndroidPlayerApi.jar')
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Make sure you have these added as gradle dependencies :-
implementation "android.arch.lifecycle:livedata:1.1.1"
implementation "android.arch.lifecycle:viewmodel:1.1.1"
implementation "android.arch.lifecycle:extensions:1.1.1"
And also make sure to add google() to your repositories in project level gradle and you are connected to internet !!
Edit
For androidx use :-
def lifecycle_version = "2.0.0"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
Add these two lines in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
when you add these two lines you will get an error in activity.
You need to modify all components from android to androidX
Eg: android.support.v7.app.AppCompatActivity to androidx.appcompat.app.AppCompatActivity
I am developing an app and add the room for database but it shows the error is
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.app.android/com.app.android.activities.AttendanceActivity}:
java.lang.RuntimeException: cannot find implementation for
com.app.android.db.AppDatabase. AppDatabase_Impl does not exist
In gradle file I have add every thing. My gradle file is shown below. I don't know. what is the problem. This code is working in another application. But it shows in this application. Kindly help me.
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'com.app.android'
minSdkVersion 14
targetSdkVersion 25
versionCode 16
// edumia versionCode 16
versionName "2.0.5"
// edumia versionName "2.0.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
jcenter()
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
maven {
url 'https://dl.bintray.com/ayz4sci/maven/'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.facebook.shimmer:shimmer:0.1.0#aar'
compile 'com.afollestad.material-dialogs:core:0.9.3.0'
compile 'com.afollestad.material-dialogs:commons:0.9.3.0'
compile 'com.facebook.stetho:stetho:1.4.1'
compile 'com.uphyca:stetho_realm:2.0.0'
compile 'com.evernote:android-job:1.1.11'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'com.android.support:design:25.0.0'
compile 'com.ss.bannerslider:bannerslider:1.6.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.ayz4sci.androidfactory:downloadprogress:1.0.2'
compile('com.alibaba.android:ultraviewpager:1.0.6#aar') {
transitive = true
}
compile 'android.arch.lifecycle:extensions:1.0.0-rc1';
compile 'android.arch.persistence.room:runtime:1.0.0-rc1';
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-rc1';
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-rc1';
}
MainActivity.java
public class AttendanceActivity extends ActionBarActivity {
private Class_ class_;
private AppDatabase database;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
database = AppDatabase.getDatabase(getApplicationContext());
database.classDao().removeAllUsers();
Class_ aClass = new Class_(1,"model");
database.classDao().addClass(aClass);
Log.d(TAG, "added success");
}
AppDatabase.java
public abstract class AppDatabase extends RoomDatabase{
private static AppDatabase INSTANCE;
public abstract ClassDao classDao();
public static AppDatabase getDatabase(Context context) {
if (INSTANCE == null) {
INSTANCE =
Room.databaseBuilder(context, AppDatabase.class, "edumiadatabase")
//Room.inMemoryDatabaseBuilder(context.getApplicationContext(), AppDatabase.class)
// To simplify the exercise, allow queries on the main thread.
// Don't do this on a real app!
.allowMainThreadQueries()
// recreate the database if necessary
.fallbackToDestructiveMigration()
.build();
}
return INSTANCE;
}
public static void destroyInstance() {
INSTANCE = null;
}
}
Class_.java
public class Class_ {
#PrimaryKey
public int id;
public String Class_;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getClass_() {
return Class_;
}
public void setClass_(String class_) {
Class_ = class_;
}
public Class_(int id, String class_){
this.id=id;
this.Class_ = class_;
}
}
ClassDao.java
#Dao
public interface ClassDao {
#Insert(onConflict = OnConflictStrategy.REPLACE)
void addClass(Class_ user);
#Query("delete from user")
void removeAllUsers();
}
I have added #Database(entities = {Class_.class}, version = 1) in AppDatabase.java . The #Database annotation for your database class, and #Entity for your entity. I have given as correct. Then the issue solved.
I faced the same problem even after adding correct dependency in my
build.gradle of my app module. My problem was ,I have used different module for separating database layer and I have moved my dependency to build.gradle of corresponding module solved my problem.
Hope this will helpful to someone else !!!
#Database annotation is missing
add annotation something like this
#Database(entities = [Articles::class], version = 1)
abstract class NewsDatabase : RoomDatabase() {
abstract fun articlesDao(): ArticlesDao
}
also for kotlin add following line to dependencies
kapt "android.arch.persistence.room:compiler:1.1.1"
also i was using kotlin and all my data class members were non nullable.
worked fine after i changed them to nullable types
I have tried a great deal debugging this issue but unable to find the cause. Dagger simply doesn't create the DaggerComponent classes. I've checked SO for duplicates but none of the solutions provided worked.
project's build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
jcenter {
url "http://jcenter.bintray.com"
}
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app's build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.hr.crux"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
retrolambda {
jvmArgs '-noverify'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
provided 'javax.annotation:jsr250-api:1.0'
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
testCompile 'junit:junit:4.12'
}
HttpModule.java
#Module
public class HttpModule {
#Provides
#Singleton
Retrofit getRetrofit() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://maps.googleapis.com/maps/api/place/")
.build();
return retrofit;
}
}
HttpComponent.java
#Singleton
#Component(modules = {HttpModule.class})
public interface HttpComponent {
void inject(MainActivity activity);
}
Application.java
public class Application extends android.app.Application {
private static Application application;
private HttpComponent appComponent;
#Override
public void onCreate() {
super.onCreate();
application = this;
appComponent = //Cannot find DaggerHttpComponent
}
public static Application getInstance() {
return application;
}
}
MainActivity.java
public class MainActivity extends AppCompatActivity {
#Inject
Retrofit retrofit;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Dagger is failing to generate the component class in my Application class. I've tried clean building, I've tried invalidating cache but nothing works.
You can start a fresh project by yourself instead of following the tutorial project. If you do so, here is the solution.
These two lines are responsible to generate the compile-time framework in Dagger 2.
compile 'com.google.dagger:dagger:2.14.1'//generates framework in compile time
annotationProcessor 'com.google.dagger:dagger-compiler:2.14.1' //generates framework in compile time based on the annotations you provided.
Full setup Dagger
//dagger 2
compile 'com.google.dagger:dagger:2.14.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.14.1'
//to enable DaggerActivity, DaggerBroadcastReceiver, DaggerFragment etc classes
compile 'com.google.dagger:dagger-android:2.14.1'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.14.1'
//support libraries with dagger 2
compile 'com.google.dagger:dagger-android-support:2.14.1'
Note: You need to configure Annotation Process as provided in the screenshot below. You can do this File>Other Settings>Default Settings>search"Annotation processor"
As Other threads' Answers does NOT work for me:
I've answered here
Pref -> Editor -> File Types -> Ignore Files And Folders -> Remove "Dagger*.java;"