AndroidManifest.xml "Unresolved package" Error - android

I am developing a Media Player app. I was implementing MediaButtonReceiver (which is used to control Media inputs given from Headphone, bluetooth like external devices).
But while declaring receiver in the manifest file I encountered a number of errors.
Errors:
Unresolved package session
Unresolved class MediaButtonReceiver
Class referenced in the manifest, com.example.android.MediaPlaybackService, was not found in the project or the libraries
Unresolved package android
Unresolved class MediaPlaybackService
build.gradle:app
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.helloworld"
minSdkVersion 16
targetSdkVersion 30
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'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld">
<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.HelloWorld">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="android.support.v4.media.session.MediaButtonReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<service android:name="com.example.android.MediaPlaybackService" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>
</application>
</manifest>

"Unresolved package/reference" means that the supporting library doesn't exist. According to the bewildering Android dev doc, you must download it by adding the following code to Gradle Scripts > build.gradle (Module: xxx.app) inside dependencies{}, resync and the error will disappear from androidx.media.session.MediaButtonReceiver
implementation("androidx.media:media:1.6.0")
and add this code for the error to disappear from android.support.v4.media.session.MediaButtonReceiver
implementation("com.android.support:support-media-compat:28.0.0")
Check latest version of androidx and v4

Maybe try to declare it in AndroidManifest.xml like the documentation said (for AndroidX) :
<receiver android:name="androidx.media.session.MediaButtonReceiver" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>

Related

I am getting blank screen after integrating google maps api in my android application

I tried integrating google maps API in my android application but I keep getting a blank grey screen. Attaching manifest and build.gradle file. The activity file contains the default code that comes while creating a google maps activity. You can clearly see this in manifest file.
I have mentioned the API key. I think the issue lies in dependencies, I might not have included every library that requires in order to run the app but I am not able to figure it out.
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mppolice">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<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.MPPolice">
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow the directions here:
https://developers.google.com/maps/documentation/android-sdk/get-api-key
Once you have your API key (it starts with "AIza"), define a new property in your
project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the
"YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
<activity
android:name=".NearbyPolice"
android:exported="false"/>
<activity
android:name=".More"
android:exported="false" />
<activity
android:name=".WomanHelpline"
android:exported="false" />
<activity
android:name=".Statistics"
android:exported="false" />
<activity
android:name=".MissingPerson"
android:exported="false" />
<activity
android:name=".NearbyOffenders"
android:exported="false" />
<activity
android:name=".Contacts"
android:exported="false" />
<activity
android:name=".CrimeReport"
android:exported="false" />
<activity
android:name=".PasswordActivity"
android:exported="false" />
<activity
android:name=".AuthScreen"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="false"
android:label="#string/title_activity_main"
android:theme="#style/Theme.MPPolice.NoActionBar" />
<activity
android:name=".SplashScreen"
android:exported="true"
android:theme="#style/Theme.MPPolice.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
apply plugin: 'com.google.gms.google-services'
android {
compileSdk 31
defaultConfig {
applicationId "com.example.mppolice"
minSdk 21
targetSdk 31
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_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation "androidx.cardview:cardview:1.0.0"
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
implementation 'com.google.firebase:firebase-auth:21.0.7'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.gms:play-services-location:20.0.0'
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.3.1')
implementation 'com.google.firebase:firebase-analytics'
}

Android plugin in Unity

i am trying to add a local .aar from an android library in Unity. Currently it is a very basic project, in unity there is just one script that opens the activity from android library on a button click.
I manually added the .aar in the /plugins/android folder (I am using 2019.4 version), and on build I keep getting the error that a resource is not found (Theme.AppCompat.Light.NoActionBar' not found in AndroidManifest)
.
This are my graddle config & AndroidManifest:
plugins {
id 'com.android.library'
}
android {
compileSdk 31
defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "com.facebook.react:react-native:+"
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
//(MainApplication) Manual ReactPackage Setup here...
apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
>
<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>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity
android:name=".ReactNativeActivity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize" />
</application>
</manifest>
I am a newbie when it comes to mobile development, but I think the issue is that the dependencies from build.graddle are not included in the .aar.
I think my options are to either create a fat .aar , manually download dependencies .aar's or to publish .aar to a central repository. Am I on the right track?
Any help is more than appriciated
I manage to get over the error by adding a custom graddle template to the unity project.

Why my emulator is throwing me the error, missing system image?

Well, actually, I am a newbie to android. I have been trying to develop an app that has google maps, and everything was going fine until today when I got this error from the emulator.
Here are some files in case it may be helpful.
Manifest XML file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.uaproject">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<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.UAProject">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".Hotels"
android:exported="true"
android:parentActivityName=".HomeScreen" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />
<activity
android:name=".NoteEditorActivity"
android:exported="true"
android:parentActivityName=".HomeScreen" />
<activity
android:name=".AboutApp"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".Copyrights"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".ToAboutBayanOlgey"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".ToAboutUs"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".Menu"
android:exported="true"
android:parentActivityName=".HomeScreen" />
<activity
android:name=".HomeScreen"
android:exported="true" />
<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>
</application>
</manifest>
build.gradle-app level
plugins {
id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.uaproject"
minSdk 19
targetSdk 31
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
}
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.github.smarteist:autoimageslider:1.3.9'
implementation 'com.google.android.material:material:<version>'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
build.gradle-root level
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
PS: By the way, if you guys have time, could you please guide me on how to add google maps to an already-created fragment(for example, my fragment is the one of a bottom navigation). I have been searching but all I tried did not work for some reason. Or just a link to the valid way would do because there seemed to be many obsolete approaches to this as well, which we beginners cannot really discern.

My manifest went missing after failing building gradle with Glide Library

I tried using the Glide library in order to load a profile picture from Facebook, in the gradle I implemented the 4.8.0 version (which is not the latest) and it made this error :
ERROR: Failed to parse XML in C:\Users\Paul Jouet\Desktop\ESILV\S5\Mobile Programming\ProjetTest2\app\src\main\AndroidManifest.xml
ParseError at [row,col]:[18,89]
Message: expected start or end tag
Affected Modules: app
My manifest module has disappeared, it is still in my project and I can open it, but not from the 'android' section... When I tried syncing again without the implementation, the error remains, I tried some solutions I found like cleaning the project and rebuild it, but none worked.
This is how the 'android' section looks like after the failed syncing, the module 'manifest' is missing even though it is still in the same location as before
Can someone explain to me how this can happen ? It makes no sense to me since I obviously deleted the part causing the problem... The only solution I could find is to recreate a project from scratch and copy paste all my code, but this is not viable since it can happen again.
Thank you for helping !
Edit : here are my manifest and gradle codes
Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.projettest2"
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 '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 'com.facebook.android:facebook-android-sdk:4.42.0'
implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
}
}
Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.projettest2">
<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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:authorities="com.facebook.app.FacebookContentProvider464643414180175" //I changed the ID
android:name="com.facebook.FacebookContentProvider"
android:exported="false" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>

App doesn't show up in Laucher List and can't be opened

I made an app, that worked just fine until yesterday.
Somehow I broke it that it doesn't show up in the Launcher's App list. I only can uninstall through the Apps tab in the Settings.
As I have already made a Beta on Play Store I tried to open it there, but there only shows up the "Uninstall" button.
I think it has to do something with the Manifest or build.gradle.
So here they are:
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.mrminemeet.reviewcheck">
<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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/*"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Information"></activity>
</application>
</manifest>
And here the build.gradle (Module: App):
apply plugin: 'com.android.application'
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
signingConfigs {
}
compileSdkVersion 27
defaultConfig {
applicationId "at.mrminemeet.reviewcheck"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName '0.1'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:gridlayout-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.google.android.gms:play-services-ads:12.0.0'
}
If you need other files just comment on them.
If you want to use multiple category then you need to create another intent-filter
like this
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Link to document
https://developer.android.com/guide/components/intents-filters.html#ExampleFilters

Categories

Resources