How to fix failed to add navigation dependency android studio java - java

I tried to add a new project using the existing template Navigation Drawer Activity. It really works well. However, I accidentally deleted the mobile_navigation.xml in res/navigation. Now that every time I tried to open a simple template (even if it is not Navigation Drawer Activity) I'm getting the below error message.
I tried:
File/Invalidate Cache/Restart: but it doesn't work
I found this implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' to update gradle but I think it is for kotlin. I'm using Java on Android Studio 3.6.2
I even tried creating a new project using templates Botton Navigation Activity. However, it is also not working and the same error occurs.
I even tried Empty Activity. Then it is weird that I'm getting an Android resource linking failed error. And it directs to a .XML (value.xml) of some of my other projects in a different folder which is not even related to this new project. I didn't even open it.
I would appreciate any suggestion to fix this. Thank you!
build.gradle is as below
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.navigation:navigation-fragment:2.4.1'
implementation 'androidx.navigation:navigation-ui:2.4.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

Related

How can I bring the PAHO/Eclipse MQTT Android Service into an Android Studio Project

I am simply not able to bring the PAHO / Eclipse MQTT Android Service into an Android Studio project.
The PAHO documentation advises you to add this line to app/build.gradle
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
But eventually I discovered that is now obsolete, and that line should actually be:
api('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
Complete app/build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.rlasater.mqttsubscriber"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.1.0'
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 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
//implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'
//This is the problematic line:
api('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
}
Result when I attempt to build:
Build failed
:app:compileDebugKotlin
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class androidx.appcompat.app.AppCompatActivity, unresolved supertypes: androidx.core.app.TaskStackBuilder.SupportParentable
app/src/main/java/com/rlasater/mqttsubscriber/MainActivity.kt
Cannot access 'androidx.core.app.TaskStackBuilder.SupportParentable' which is a supertype of 'com.rlasater.mqttsubscriber.MainActivity'. Check your module classpath for missing or conflicting dependencies
<Previous line repeated several times ...>
Compilation error
What needs to be done so an Android Studio project can include the MQTT Android Client?
Why does that problematic line disrupt the basic Android class AppCompatActivity? That makes absolutely no sense.
Any suggestions would be most appreciated. I can't find any documentation on the PAHO MQTT Java/Kotlin more recent than some years ago. I have been able to get simpler classes (MqttClient) to work in the Studio. Obviously getting this Service working would be most beneficial.
Use following dependencies in build.gradle and check:
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.2'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
Documentation is not up to date.
dependencies {
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.4'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
// other dependencies
}
Latest releases You will find here
https://repo.eclipse.org/content/repositories/paho-releases/org/eclipse/paho/org.eclipse.paho.client.mqttv3/
https://repo.eclipse.org/content/repositories/paho-releases/org/eclipse/paho/org.eclipse.paho.android.service/

APK generated using Android Studio is not getting installed on certain devices

I generated an apk with Android Studio without problem, but when I try to Install in my phone android v4.4.2 this error show me "
the app was not installed"
I don't understand, this is the configuration:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.ejemplogpsmaps"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
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.google.android.gms:play-services-maps:16.1.0'
}
then I tried to install on another phone, Samsung Galaxy s4 android v5.0.1 and the same error was displayed
First, check if the app been installed via USB.
then check if the flavour is release and not debug. if it's in debug then try building another one with the release version selected
Android Jelly Bean 4.2.x is actually API level 17, which has to be declared accordingly:
minSdkVersion 17
And also, the Google Play Services plugin is missing:
apply plugin: "com.google.gms.google-services"

Missing components in material google library on Android

I am trying to use SwitchMaterial component within an Android project, however Android studio cannot find it at design time, and including it within my xml layouts causes a ClassNotFoundException at runtime.
Recent Android studio project so is already setup using AndroidX
'com.google.android.material:material:1.0.0' is in my dependencies and gradle syncs with no errors
Some other Material components are present, eg I am using MaterialButton on the same XML/Activity
Unable to find com.google.android.material.switchmaterial.SwitchMaterial in xml
Unable to import com.google.android.material.switchmaterial.SwitchMaterial when trying to add to activity java unit
Build settings : Compile SDK = 29 Build Tools = 29.0.2 Min SDK = 19 Target SDK = 29
There are no proguard rules setup (At all) so should not be messing with it
Spent an hour googling answers - nothing on SO, or the Android / Material Docs
Cannot find SwitchMaterial even though other components are there
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "my.app.id"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "6g"
}
lintOptions {
lintConfig file("lint.xml")
showAll false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.bumptech.glide:glide:4.10.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.code.gson:gson:2.8.6'
}
XML layout
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="#+id/login_notificationsSwitchFamily"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_10"
android:checked="true"
android:text="Family Friendly"
android:textSize="#dimen/textSize_16" />
Any help is appreciated. I cannot see why there would be missing components.
You need the version 1.1.0 of the material components library.
Currently
implementation 'com.google.android.material:material:1.1.0'

Build Errors in Android Studio Gradle: It works fine when I remove the google dependency

So I am assuming I have differing versions of dependencies causing this issue but i cant seem to resolve it.
When I add the dependency: implementation 'com.google.android.gms:play-services-vision:18.0.0' Then I get an error Syncing my build gradle.
When I change the version to implementation 'com.google.android.gms:play-services-vision:15.0.0' Then It Syncs fine but my app keeps crashing as soon as I open it.
Please can someone help me sync my versions so my app doesnt crash.
I changed the version from 18.0.0 to 15.0.0.
My gradle:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.ecommerce"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.rey5137:material:1.2.5'
implementation 'com.android.support:cardview-v7:+'
implementation 'com.android.support:recyclerview-v7:+'
implementation 'io.paperdb:paperdb:2.6'
implementation 'com.android.support:design:28.0.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.android.gms:play-services-vision:18.0.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.sup`enter code here`port.test.espresso:espresso-core:3.0.2'
}
After some research I actually found out that Google stopped updating com.google.android.gms:play-services after 12.0.1. I changed the versions as well as my Firebase versions. Everthing Synced with no errors and seems to be running fine now.
first go to file and sync project with gradle file.. if it repeat itself, then go to file and invalidate caches/Restart it has work for me alot of time and also try and replace minSdkVersion 15 to minSdkVersion 21 and also with the look of it your firebase dependence are old check out https://firebase.google.com/docs/android/setup or google firebase dependencies
also make sure you add allprojects
{
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
to your build.gradle

Null Value In Entry: Stream Output Folder Is Null

I am working on Android Application using the Fire base Database. All the data stored perfectly on the Fire base.
The Problem comes when I make some changes and close the Application by Forcing android Studio to be Shut Down.
Now When I open Android to built Project It Gives Error of Stream output Folder as Null.
I have searched on Stack Overflow and find an answer with my Error Resemblance but I didn't understand the Answer completely.
Answer Searched
Here is my App Gradle Code
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.usmanali.medicineinvent"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
The dependancies in App Gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
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'
}
here is build. Gradle File
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
This problem is just Resolved by Deleting the .Gradle File in the Project Folder.
After .gradle File Deletion;
Built and Clean the Project.

Categories

Resources