What is causing the "error: attribute mapbox_styleUrl not found"? - java

I keep getting the error "attribute mapbox_styleUrl not found" when trying to implement the Navigation SDK of Mapbox into my project.
I think it has to do with the migration of the Map SDK to 7.0.0 where they removed the mapbox_styleUrl XML attribute, but I'm unable to find a way to fix this.
I'm not using the styleUrl in any of my code. I leave the map style in my layout default and set it in onMapReady.
This is the complete error:
Android resource linking failed
Output: C:\Users\Jonas\.gradle\caches\transforms-1\files-1.1\mapbox-android-navigation-ui-0.26.0.aar\0ea5c6919c35d65de36f46fe7fce49d7\res\layout\navigation_view_layout.xml:10: error: attribute mapbox_styleUrl (aka com.fishdev.planmyrun:mapbox_styleUrl) not found.
error: failed linking file resources.
Complete build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.fishdev.planmyrun"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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'
// Mapbox dependencies
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.0.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.4.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.26.0'
}
My MapView in layout:
<com.mapbox.mapboxsdk.maps.MapView
android:id="#+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="50.87485515"
mapbox:mapbox_cameraTargetLng="4.707931288875566"
mapbox:mapbox_cameraZoom="11"
/>

I happened to come across the exact same issue today whilst migrating an Android app from Mapbox Android SDK 6.5.0 to 7.0.0.
I too had no mapbox_styleUrl usages in my code, so I spent a little time scratching my head before I noticed that the error references mapbox-android-navigation-ui-0.26.0 which appears to be utilising this attribute (removed in Mapbox Android SDK 7.0.0). Taking a deeper look into the Mapbox Navigation Android repository, I noticed that the latest commit (from ~6 hours ago) of mapbox-android-navigation-ui had brought everything up to date with the Mapbox Android SDK 7.0.0.
Since these fixes had not been packaged in an official release as yet, I added the latest snapshot release to my project by updating my dependencies via Gradle:
repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.27.0-SNAPSHOT'
}
I sincerely hope that saves you a headache!

Related

How to fix failed to add navigation dependency android studio 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'
}

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/

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

How to resolve java.lang.NoClassDefFoundError in Unity android plugin

I am trying to make an android plugin for my Unity project that displays a notification bar with some actions. I export the android plugin as an AAR file and import it into Unity. This was all working fine, up until just yesterday when I wrote in some minor new features. I built the module, re-imported the aar into unity, and pushed to a device, only to get this error when the app tries to instantiate a NotificationCompat.Builder:
java java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/NotificationCompat$Builder
The strange thing is that prior to yesterday the notification was working just fine, and I have no idea how code I changed could result in a run-time error like this. I have somehow messed up the integration pipeline from my plugin to Unity, and have no idea how I caused it or how to fix it.
I have seen related posts that claim you need to manually inject dependent libraries from the sdk into unity. However, I find this hard to believe because it was working fine and I have never had to do any of that. I did go ahead and try sticking "support-v4-25.3.1.aar" from the sdk into the plugins folder, but to no avail, same error on trying to display the notification.
Here's the basic setup:
MyService.java:
import android.support.v4.app.NotificationCompat;
...
public void showNotification(){
mNotificationManager.cancelAll();
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = mNotificationManager.getNotificationChannel(id);
if (mChannel == null) {
mChannel = new NotificationChannel(id, title, importance);
mChannel.setSound(null, null);
mNotificationManager.createNotificationChannel(mChannel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(),id);
builder.setSmallIcon(R.drawable.audiotilesplayer_notification);
builder.setContentTitle("MyApp");
builder.setContentText("App is running");
builder.setContentIntent(contentIntent);
builder.addAction(buttonID, "Do Some Action",
buttonPendingIntent);
Notification noti = builder.build();
mNotificationManager.notify(NOTIFY_ID, builder.build());
}
...
And the module's build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7: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'
implementation files('libs/classes.jar')
implementation 'com.android.support:support-compat:28.0.0'
}
The app crashes on java NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(),id); with the described error. What's very curious to me is that this is a runtime error and not a compile time error... I don't quite understand the mechanics of unity-android plugins, but missing a class definition sounds like something that should fail at compile time (unless this is some funky reflection shenanigans unity is doing to push off resolution?). I have been pulling my hair out over how this could have gotten messed up when I have changed nothing about my build process, any advice greatly appreciated!
Encountered same issue. Managed to fix it by copying dependencies from Android Studio to Unity mainTemplate.gradle. The dependencies I had to copy were
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
Here is how my how mainTemplate.gradle looks on empty unity project, with just android plugin. Unity 2019.3, enabled mainTemplate from publishing settings.
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES****SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**

Categories

Resources