com.google.android.material.R Cannot resolve symbol 'R' for BottomNavigationView - r

I use BottomNavigationView in my App, but I have a problem: in BottomNavigationView.java there is import com.google.android.material.R and R is red and write "Cannot resolve symbol 'R'".
The topics I saw couldn't help me.
What would you recommend for me?
The dependencies:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.yourspeakingclub"
minSdkVersion 24
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java/Models', 'src/main/java/com/salendor/yourspeakingclub/models']
}
}
buildToolsVersion = '28.0.3'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:support-compat'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
implementation 'com.google.android.material:material:1.1.0-beta01'
}
The layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/navigation_container_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?android:attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation_element"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_gravity="start"
android:background="?android:attr/windowBackground"
app:itemTextColor="#000000"
app:labelVisibilityMode="unlabeled"
app:itemIconTint="#color/colorBlack"
app:menu="#menu/bottom_menu" />
</FrameLayout>
The class definition where is the problem with 'R' is available here: https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/bottomnavigation/BottomNavigationView.java
Thanks

I experienced this problem when I updated Gradle to the latest version. When I returned to version 3.1.3 the error simply disappeared
change this in your build.graddle (project)
classpath 'com.android.tools.build:gradle:3.1.3'

The error should be resolved by doing Alt+Enter & adding the right import. But I'm guessing this issue came out of nowhere after you had already built & run the project at least once (as it once happened with me).
This could be because you're unable to reference the elements of the XML layout. In this case, try:
Build -> Clean project
.
This resolved my issue. Hopefully, it'll help you too :)

I had the same problem.
Simply updated this tool in build.graddle (project) file
classpath 'com.android.tools.build:gradle:4.1.0'
and it worked !!

Related

Kotlin app using Admob and Firebase, but the app doesn't run, saying that there is a problem with the Firebase SDK

I made an app using Firebase and Admob, and the Kotlin app, which worked fine, doesn't work after wipe data from the emulator. The error code is as follows.
"The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firebase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date"
I've tried resetting firebase, but it still won't launch. What's wrong?
The build gradle and manifest are attached below.
build gradle(project)
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
// classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.gms:google-services:4.3.13'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build gradle(module)
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.jym.qb"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// implementation platform('com.google.firebase:firebase-bom:30.4.1')
implementation platform('com.google.firebase:firebase-bom:31.1.0')
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.android.gms:play-services-ads:19.6.0'
implementation 'com.google.firebase:firebase-auth-ktx:21.1.0'
implementation 'com.google.android.gms:play-services-auth:20.4.0'
}
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jym.qb">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Qb"
android:name=".SharedValue"
>
<activity
android:name=".ManageQuestionActivity"
android:exported="false" />
<activity
android:name=".KeywardActivity"
android:exported="false" />
<activity
android:name=".UpdateActivity"
android:exported="false" />
<activity
android:name=".GetQuestionActivity"
android:exported="false" />
<activity
android:name=".WorkbookActivity"
android:exported="false" />
<activity
android:name=".PartActivity"
android:exported="false" />
<activity
android:name=".ExamActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxx~xxxxxxxxxxx" />
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
After taking a walk to cool off for an hour, the app works normally. Looking at the Google Admob documentation, I found the following:
"Key Point: New test devices typically start serving test ads in your app within 15 minutes, but it can also take up to 24 hours."
While initializing the data of the virtual emulator, it seems that Admob recognizes it as a new mobile phone and delays the time. Could it be that what I was thinking was correct?

React Native app crashes when calling .getToken() on #react-native-firebase/messaging

I am a developing a bare react native app with react native cli.
I recentlty integrated firebase and installed #react-native-firebase/messaging.
When calling .getToken() of messaging
import messaging from '#react-native-firebase/messaging';
await messaging().getToken() <------------ CAUSING APP TO CLOSE
Everytime I add this line the app closes without any warnings and logs, It dosen't happen when I comment the line
Here's my AndroidManifest.XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.NAME.NAME">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-9772207663610474XXXXXXXXXX"/>
<meta-data
android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="false"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data
android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="#color/white"/> <!-- or #android:color/{name} to use a standard color -->
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
</application>
Here's the Android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
googlePlayServicesVersion = "+"
firebaseVersion = "+"
firebaseMessagingVersion = "+"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}}
Did you add this line to your Android/app/build.gradle?
implementation platform(‘com.google.firebase:firebase-bom:28.0.1’)
If you did, try to remove it, clean, rebuild and run the project again.
firebaseMessagingVersion = "21.1.0"
resolve my issue.
Updating to "#react-native-firebase/messaging": "^11.5.0" in package.json and changing firebaseMessagingVersion = "21.1.0" in the buildscript.ext of android/build.gradle resolved the issue for me.
Check messaging permission before the executing this line.
_checkPermission = async() => {
const enabled = await firebase.messaging().hasPermission();
if (enabled) {
const device = await firebase.messaging().getToken()
console.warn(device)
}
else this._getPermission()
}
_getPermission = async() => {
firebase.messaging().requestPermission()
.then(() => {
this._checkPermission()
})
.catch(error => {
// User has rejected permissions
});
}

Import Less-Files from Classpath (Bootstrap Webjars)

I want to generate my CSS-Files from Less-Files via LessCss-Gradle-Plugin (https://github.com/obecker/gradle-lesscss-plugin).
In my build.gradle I added the webjar-dependencies for bootstrap and so on..
dependencies {
implementation project(':pet-clinic-data')
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.3.2.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:2.3.2.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE'
implementation 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
implementation 'org.webjars:webjars-locator-core:0.45'
implementation 'org.webjars:jquery:2.2.4'
implementation 'org.webjars:jquery-ui:1.11.4'
implementation 'org.webjars:bootstrap:3.3.6'
runtimeOnly 'org.springframework.boot:spring-boot-devtools:2.3.2.RELEASE'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.3.2.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '5.2.8.RELEASE'
}
And my lesscss-Task:
lesscss {
source = fileTree('src/main/less') {
include '**/*.less'
}
dest = "$buildDir/resources/main/static/resources/css"
dependencies {
compile 'org.webjars:bootstrap:3.3.6'
compileClasspath 'org.webjars:bootstrap:3.3.6'
}
}
I have some less-Files that require Elements from classes in the bootstrap-webjar (for example: label-success). I have the webjar in my external dependencies, but how can I use the #Import-Statement to link to that?
I tried something like:
#import "classpath: resources/webjars/bootstrap/3.3.6/less/bootstrap.less";
#import "classpath:META-
INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less"

Firebase Ui auth version 3.2.2 xml errors

I am trying to connect a firebaseUI auth but I keep getting an error with an unknown xml file
Here is my build gradle files:
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
resConfigs "auto"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'junit:junit:4.12'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.firebaseui:firebase-ui-auth:3.2.2'
}
apply plugin: 'com.google.gms.google-services'
and here is the xml file which appears:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.AppCompat" parent="Base.V26.Theme.AppCompat"/>
<style name="Base.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light"/>
<style name="Base.V26.Theme.AppCompat" parent="Base.V23.Theme.AppCompat">
<!-- We can use the platform styles on API 26+ -->
<item name="colorError">?android:attr/colorError</item>
</style>
<style name="Base.V26.Theme.AppCompat.Light" parent="Base.V23.Theme.AppCompat.Light">
<!-- We can use the platform styles on API 26+ -->
<item name="colorError">?android:attr/colorError</item>
</style>
<style name="Base.V26.Widget.AppCompat.Toolbar" parent="Base.V7.Widget.AppCompat.Toolbar">
<item name="android:touchscreenBlocksFocus">true</item>
<item name="android:keyboardNavigationCluster">true</item>
</style>
<style name="Base.Widget.AppCompat.Toolbar" parent="Base.V26.Widget.AppCompat.Toolbar"/>
</resources>
Here are the errors which appear from this:
[:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
Error:(252, 5) error: resource android:attr/keyboardNavigationCluster not found.
Error:(252, 5) error: resource android:attr/fontStyle not found.
Error:(252, 5) error: resource android:attr/font not found.
Error:(252, 5) error: resource android:attr/fontWeight not found.
C:\and-nd-firebase-1.00-starting-point\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml
Error:(36) error: style attribute 'android:attr/autofillHints' not found.
Error:(7) resource android:attr/colorError not found.
Error:(11) resource android:attr/colorError not found.
Error:(15) style attribute 'android:attr/keyboardNavigationCluster' not found.
Error:(18) style attribute 'android:attr/keyboardNavigationCluster' not found.
Error:(24) style attribute 'android:attr/autofillHints' not found.
Error:(28) style attribute 'android:attr/autofillHints' not found.
Error:(32) style attribute 'android:attr/autofillHints' not found.
Error:(36) style attribute 'android:attr/autofillHints' not found.
C:\and-nd-firebase-1.00-starting-point\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(250) resource android:attr/keyboardNavigationCluster not found.
Error:(468) resource android:attr/fontStyle not found.
Error:(468) resource android:attr/font not found.
details
Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt
Information:BUILD FAILED in 8s
Information:29 errors
Information:0 warnings
Information:See complete output in console
Any help would be much appreciated.
Use version 27.0.2 of the Support libraries:
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
And change:
compileSdkVersion 27 // was 24
You may also want to use the latest version of Glide:
compile 'com.github.bumptech.glide:glide:4.3.1'

Gluon-eclipse stuck at a very old version (like 1.0)

I just recently installed the gluon-eclipse plugin so I could make javafx based android apps, but whenever I tried to run the apks it generated I kept getting a black screen. I think I'm using a very old edition and don't know where to get the update, I searched gluon on the eclipse marketplace abd it gave me 1.0 again. I also tried the search for updates thing and that didnt work either.
Any help is appreciated
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b10'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
}
mainClassName = 'com.zach.apcs.APCSHelper'
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
}
}

Resources