Android - Build failed with an exception while running react-native run-android - android

I am trying to setup remote push notifications in react-native and I am using the react-native-fcm package for fulling that.I followed the guide in setting up the required things from the github page of the package .I keep running in to the following error and I am not sure what is missing or if I am doing something wrong .
Error :
:app:processDebugResources
C:\Users\test\Desktop\App_Dev\pushNotifyDev\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:58:31-47:
AAPT: No resource found that matches the given name (at 'resource' with value '#mipmap/ic_notif').
C:\Users\test\Desktop\App_Dev\pushNotifyDev\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:56: error: Error: No resource found that matches the given name (at 'resource' with value '#mipmap/ic_notif').
:app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 16.121 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Here is my AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pushnotifydev"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="#mipmap/ic_notif"/>
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<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" />
</application>
</manifest>
I am using the following
React-native -0.53
Android Studio -3.0.1
Any help in debugging this would greatly be appreciated.
Thanks

Related

required to specify an explicit value for `android:exported` in the Debug/androidMenifest.xml for flutter_local_notification

The error shows that I need to add android:exported in the debug/androidMenifest.xml . But there is no activity defined the file . so I am not sure what can I do . I tried changing the compileSDK version in the build.gradle but that also didnt to anything .
here is the error
Console:
C:\Users\vinay\AndroidStudioProjects\fc-ui\android\app\src\debug\AndroidManifest.xml:15:9-22:20 Error:
android:exported needs to be explicitly specified for element <receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : android:exported needs to be explicitly specified for element <receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
my app/androidMenifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.firstcotton.k">
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
<application
android:label="First Cotton"
android:name="${applicationName}"
android:icon="#mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:exported="false"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
my debug/androidMenifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.firstcotton.k">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Can you help me? How can I fix this problem?
Thank you so much.
after adding the file this is the new error -
Exception occurred while executing 'start':
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.RUN flg=0x30000000 cmp=com.firstcotton.k/.MainActivity (has extras) } from null (pid=31748, uid=2000) not exported from uid 10381
at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1334)
at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1281)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:890)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1872)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1743)
at com.android.server.am.ActivityManagerService.startActivityAsUserWithFeature(ActivityManagerService.java:3543)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:596)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:201)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10487)
at android.os.Binder.shellCommand(Binder.java:986)
at android.os.Binder.onTransact(Binder.java:860)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:6049)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3034)
at android.os.Binder.execTransactInternal(Binder.java:1220)
at android.os.Binder.execTransact(Binder.java:1179)
Command: C:/Users/vinay/AppData/Local/Android/Sdk\platform-tools\adb.exe -s RZCT105Z0WN shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true --ez start-paused true com.firstcotton.k/com.firstcotton.k.MainActivity
I hope this helps you.
In the AndroidManifest.xml
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
...>
<activity
...
android:exported="true">
...
</activity>
<receiver
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
It's a requirement because an intent-filter is declared for your activity. So simply do this:
android:exported="true" >
<intent-filter>
...
</intent-filter>
Add that before any intent-filter declaration and you're good to go.

Why my Flutter app is not building while executing?

I have been trying to build a flutter app. But while exporting/building it an error came. The error message while building:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart:1
C:\dev\bmi\android\app\src\main\AndroidManifest.xml Error:
Package name 'BMI' at position AndroidManifest.xml:2:5-18 should contain at least one '.' (dot) character
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : Package name 'BMI' at position AndroidManifest.xml:2:5-18 should contain at least one '.' (dot) character
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 21s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
andriodmainifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="BMI">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Error is on your package name given in manifest file.
You can add package name as com.bmi or so on.
Kindly refer below added manifest file from my project.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bmi">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme" />
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.flutter.network-policy"
android:resource="#xml/network_security_config" />
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

gradle build error in Androidmanifest.xml file

I am trying to build an android application using gradle in eclipse and i am trying to build the apk using command gradle build in project root directory,
i am getting an error in the path of
$projdir/build/intermediates/manifests/full/release/Androidmanifest.xml
saying that
/build/intermediates/manifests/full/release/AndroidManifest.xml:139:28-68: AAPT: No resource found that matches the given name (at 'theme' with value '#style/Theme.AppCompat.Light.NoActionBar').
When i open eclipse and it is redirecting me to the resource fine and it is showing no errors. And i think the Androidmanifest.xml in the above path is it necessary ??
Use AppTheme like this :-
<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=".activity.SplashActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Execution failed for task ':processDebugResources' on Ionic

I have an issue with Ionic command : Ionic build android
Here the tutorial Salesforce i'm following to create an app connected to the Salesforce API. (contact, etc.).
Now, when i mudt build android, I have this issue :
:processDebugResources
/home/r.**/Workspace/IonicApp/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml:32: error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/sf__icon').
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
>
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/usr/local/android-sdk-linux/build-tools/25.0.0/aapt package -f --no-crunch -I /usr/local/android-sdk-linux/platforms/android-23/android.jar -M /home/r.**/Workspace/IonicApp/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/r.**/Workspace/IonicApp/platforms/android/build/intermediates/res/debug -A /home/r.**/Workspace/IonicApp/platforms/android/build/intermediates/assets/debug -m -J /home/r.**/Workspace/IonicApp/platforms/android/build/generated/source/r/debug -F /home/r.**/Workspace/IonicApp/platforms/android/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.ionicframework.ionicapp508454 -0 apk --output-text-symbols /home/r.**/Workspace/IonicApp/platforms/android/build/intermediates/symbols/debug
Error Code:
1
Output:
/home/r.**/Workspace/IonicApp/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml:32: error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/sf__icon').
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.305 secs
Error: /home/r.**/Workspace/IonicApp/platforms/android/gradlew: Command failed with exit code 1
I restart the tutorial 2 times and i still have this error. Maybe because I do an Android App and not an Ios like the tutorial.
What is this file missing and where is it supposed to be?
If you need the XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ionicframework.ionicapp508454"
android:hardwareAccelerated="true"
android:versionCode="18"
android:versionName="0.0.1" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.ionicframework.ionicapp508454.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.ionicframework.ionicapp508454.permission.C2D_MESSAGE" />
<application
android:name="com.salesforce.androidsdk.phonegap.app.HybridApp"
android:hardwareAccelerated="true"
android:icon="#drawable/sf__icon"
android:label="#string/app_name"
android:manageSpaceActivity="com.salesforce.androidsdk.ui.ManageSpaceActivity" >
<activity
android:name="com.adobe.phonegap.push.PushHandlerActivity"
android:exported="true" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.ionicframework.ionicapp508454" />
</intent-filter>
</receiver>
<service
android:name="com.adobe.phonegap.push.GCMIntentService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.adobe.phonegap.push.PushInstanceIDListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name="com.adobe.phonegap.push.RegistrationIntentService"
android:exported="false" />
<activity
android:name="com.salesforce.androidsdk.phonegap.ui.SalesforceDroidGapActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
Some info:
I create an Android App.
Cordova-android is version 5.0.0 because 6.0.0 do a mismatch issue with the api salesforce.
I'm a beginner with Ionic/Cordova and mobile dev. Maybe the solution is oubvious.
The error output suggests that the build just fails due to a missing icon resource: No resource found that matches the given name (at 'icon' with value '#drawable/sf__icon').
The SalesforceSDK includes those files though, however they do not seem to be added to the Android project correctly:
https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin/tree/master/src/android/libs/SalesforceSDK/res
Copy-pasting might resolve the problem though, still wondering why the plugin does not add the drawables as expected in the res/drawable folder!

Manifest merger failed with multiple errors when adding firebase messaging service to my AndroidManifest.xml file

I was hoping to add Firebase cloud messaging to my app. I followed codelab tutorial for this and it was working correctly for the sample app, but when I try to add <service> tags to my application Manifest merger errors occurs.
The strange part is that it is working without adding those services to my Manifest file!
Here it is the error:
Error:packageName/app/src/main/AndroidManifest.xml:52:9-58:19 Error:
Element service#packageName.firebase.MyFirebaseInstanceIdService at AndroidManifest.xml:52:9-58:19 duplicated with element declared at AndroidManifest.xml:44:9-50:19
packageName/app/src/main/AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugManifest'.
Manifest merger failed with multiple errors, see logs
Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
And this is part of my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.violete.selfienight">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="net.violete.selfienight.leafpic.MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme.FullScreen">
<activity
android:name=".CameraActivity"
android:icon="#mipmap/ic_launcher"
android:label="#string/title_camera_activity"
android:screenOrientation="landscape"
android:taskAffinity=".CameraActivity"
android:theme="#style/AppTheme.FullScreen">
<intent-filter android:label="#string/app_name">
<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.version"
android:value="#integer/google_play_services_version" />
<service
android:name=".firebase.MyFirebaseInstanceIdService"
>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".firebase.MyFirebaseInstanceIdService"
>
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
...
</application>
</manifest>
My question is that whether Firebase library adds these tags to my Manifest during building or something is wrong here?
You have the same service (.firebase.MyFirebaseInstanceIdService) listed twice. This will not work. Either have one <service> element containing two <intent-filter> elements, or have two separate services with separate classes.
I had the same problem and got fixed by changing the value of minSdkVersion from 15 to 16.

Categories

Resources