I am using React Native Visual Studio Code - PC having issues with the API. I know I have it setup for billing so the API should work on that end. Any ideas how to resolve this? I have tried to follow all the steps to set it up but nothing seems to resolve it. I have looked at the documentation and I believe I have done all the steps. Picture of full error below.
AndroidManifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tool_right">
<uses-permission android:name="android.permission.INTERNET" />
<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>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="My API Key is here just not displayed here for security reasons"/>
<!-- You will also only need to add this uses-library tag -->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
</manifest>
build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
playServicesVersion = "17.0.0"
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
enter image description here
Related
I have this error "..app\src\main\AndroidManifest.xml:27:9-33:20 Error:
android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. 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.
...app\src\main\AndroidManifest.xml:34:9-40:20 Error:
android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. 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.
...app\src\main\AndroidManifest.xml:41:9-47:20 Error:
android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. 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
and don't know what should I do
Manifest 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.part3_2">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:allowBackup="true"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Part3_2"
tools:ignore="DataExtractionRules">
<activity
android:name=".MainActivity">
</activity>
<activity
android:name=".MainActivity2"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".OverlayService"
android:exported="false"
android:enabled="true"
android:foregroundServiceType="mediaProjection">
</service>
</application>
</manifest>
build.gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdk 30
defaultConfig {
applicationId "com.example.part3_2"
minSdk 28
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'
}
}
ext{
fragment_version = "1.3.0-alpha07"
activity_version = "1.3.0"
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
// implementation 'androidx.fragment:fragment-ktx:1.6.0'
implementation("androidx.fragment:fragment-ktx:$fragment_version")
debugImplementation("androidx.fragment:fragment-testing:$fragment_version")
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.2.0'
implementation 'com.google.firebase:firebase-firestore-ktx:24.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation("androidx.activity:activity-ktx:$activity_version")
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.4"
}
repositories {
google()
mavenCentral()
}
I fixed this issue by adding this line :
android:exported="true"
in my androidManifest.xml file
<activity
android:name=".MainActivity"
android:exported="true"
...
This also can happens bc a library or a dependency that gradle download automatically..
Try to run removing dependencies or libraries until you find the one that throws u this error.
Let me know if you find the solution. Thank you.
I got that error as well in my flutter project, I solved by adding this to. the application section in the android manifest.
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:exported="false" />
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:exported="false" />
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:exported="false" />
Hope this help!!
There must be exported tag on each component, that has been declared on manifest file and you are missing it on MainActivity component.
Change this from
<activity
android:name=".MainActivity">
To
<activity
android:name=".MainActivity"
android:exported="false">
</activity>
The dependencies used in the project are
"dependencies": {
"agora-react-native-rtm": "^1.5.0",
"react": "17.0.2",
"react-native": "0.68.2",
"react-native-agora": "^3.7.0"
},
Error log is
Note: Recompile with -Xlint:deprecation for details.
D:\Desktop\Codes\AgoraDemo\agorademo\android\app\src\main\AndroidManifest.xml
Error:
android:exported needs to be explicitly specified for . 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.
Here is the manifest file:
<uses-permission android:name="android.permission.INTERNET" />
<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|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
BTW: Project works fine if all the agora related dependencies is removed
Solution:
For SDK 31 there is some issue with the "react-native-agora": "^3.7.0" version which will be fixed in a new one, meanwhile you can proceed with the workaround
https://github.com/AgoraIO-Community/react-native-agora/issues/496#issuecomment-1126508840
I want to make a splash screen using react-native-bootsplash. I have followed the instructions on npm and the library is installed properly but I am not able to understand how to use it. Can someone give me an example or a small code snippet that I can write in App.js and get started. A basic example would do fine.
Here is how I integrated with RN 0.62.2:
Step 1: Add the package to react-native project
yarn add react-native-bootsplash
Step 2: Generate assets for bootscreen.
yarn generate-bootsplash
...
yarn run v1.19.0
$ /Users/sresu/personal/startups/chill/code/chill-app-rn/node_modules/.bin/generate-bootsplash
✔ The path to the root of your React Native project … .
✔ The path to your static assets directory … assets
✔ Your original icon file … assets/bootsplash_logo_original.png
✔ The bootsplash background color (in hexadecimal) … #FFF
✔ The desired icon width (in dp - we recommend approximately ~100) … 100
✔ Are you sure? All the existing bootsplash images will be overwritten! … yes
👍 Looking good! Generating files…
✨ android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png (100x100)
✨ android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png (150x150)
✨ android/app/src/main/res/mipmap-xxhdpi/bootsplash_logo.png (300x300)
✨ ios/chill/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo#2x.png (200x200)
✨ ios/chill/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo#3x.png (300x300)
✨ assets/bootsplash_logo.png (100x100)
✨ assets/bootsplash_logo#1,5x.png (150x150)
✨ assets/bootsplash_logo#2x.png (200x200)
✨ assets/bootsplash_logo#3x.png (300x300)
✨ assets/bootsplash_logo#4x.png (400x400)
✨ android/app/src/main/res/mipmap-xxxhdpi/bootsplash_logo.png (400x400)
✨ ios/chill/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo.png (100x100)
✨ android/app/src/main/res/mipmap-xhdpi/bootsplash_logo.png (200x200)
✨ ios/chill/BootSplash.storyboard
✨ android/app/src/main/res/drawable/bootsplash.xml
✨ android/app/src/main/res/values/colors.xml
✅ Done! Thanks for using react-native-bootsplash.
✨ Done in 10.86s.
Step 3: Update this file -> android/app/src/main/java/com/chill/MainActivity.java
import com.zoontek.rnbootsplash.RNBootSplash; //<- add this import statement
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
#Override
protected String getMainComponentName() {
return ....
}
// Add this for splash screen
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- display the generated bootsplash.xml drawable over our MainActivity
}
}
Step 4: Modify android/app/src/main/res/values/styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>
<!-- Add the following lines -->
<!-- BootTheme should inherit from AppTheme -->
<style name="BootTheme" parent="AppTheme">
<!-- set the generated bootsplash.xml drawable as activity background -->
<item name="android:background">#drawable/bootsplash</item>
</style>
</resources>
Make sure you should have this file - android/app/src/main/res/drawable/bootsplash.xml, this is generated from Step 2.
Step 5: Modify android/app/src/main/AndroidManifest.xml
...
<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="adjustPan"
android:exported="true">
<!-- android:windowSoftInputMode="adjustResize">-->
</activity>
<!-- add the following lines (use the theme you created at step 3) -->
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="#style/BootTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="chill" />
</intent-filter>
<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:host="chill.com"
android:scheme="https" />
</intent-filter>
<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:host="chill.com"
android:scheme="http" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
...
Last step: Hide splash screen when app is ready
class App extends React.Component<Props, State> {
componentDidMount() {
RNBootSplash.hide({duration: 250}); // fade
...
Official docs: https://github.com/zoontek/react-native-bootsplash
🤗 Hope this helps.
i am building an app that need to support only rtl layout no matter what is the phone language.
my problem is when i am in debug mode its work just fine and show the layout rtl as i wanted regardless the phone language but after i release the app it show the the layout direction as the phone language.
can anyone tell me what it may be ?
i tried the following solution:
add this line in the constructor of the main page
I18nManager.allowRTL(true);
I18nManager.forceRTL(true);
also add this line in android manifest:
android:supportsRtl="true"
both in activity tag and also in application tag
manifest :
<uses-permission android:name="android.permission.INTERNET" />
<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"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:supportsRtl="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" />
</application>
constructor in App.js
constructor(){
super();
I18nManager.allowRTL(true);
I18nManager.forceRTL(true);
}
this is the good result
https://i.imgur.com/S2nV0a4.jpg
this one is not what i want
https://i.imgur.com/VXzYWI1.png
Add these three lines in your MainActivity.java
+ import com.facebook.react.modules.i18nmanager.I18nUtil;
#Override
public void onCreate() {
super.onCreate();
// FORCE RTL
+ I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
+ sharedI18nUtilInstance.allowRTL(getApplicationContext(), true);
....
}
I have a problem with the splashscreen on Android. Here is everything what I am doing:
Creating background_splash.xml file:
xml version="1.0" encoding="utf-8"?>
layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="#android:color/darker_gray"/>
<item>
<bitmap
android:gravity="center"
android:src="#drawable/splash"/>
</item>
I remove < in the first two lines because stackoverflow cannot display them. This file is located in drawable.
I added the following to styles.xml:
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
and this is my manifest files:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
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">
<activity
android:name=".SplashActivity"
android:label="#string/app_name"
android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
And also the activity:
import android.content.Intent;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
public class SplashActivity extends ReactActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
This is the error I have:
Starting the app on 51d123cc (adb -s 51d123cc shell am start -n com.test/.MainActivity)...
Starting: Intent { cmp=com.test/.MainActivity }
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.test/.MainActivity } from null (pid=20601, uid=2000) not exported from uid 11152
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:2589)
at com.android.commands.am.Am.runStart(Am.java:768)
at com.android.commands.am.Am.onRun(Am.java:307)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:102)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:255)
UPDATE:
To the answer of #Ankit Prajapati I will add also that I set
android:largeHeap="true"
which was an error from Android Studio (running from the terminal this error wasn't reported) and this happen after changing activity to SplashActivity.
Also it was necessary to change edit configurations and changing "Launch Activity" to "Specified Activity" and setting com.test.SplashActivity.
Second way of managing splash screen on Android and which I use right now is with this tutorial:
Splash Screen Android
Try using this in
android:exported="true" in the manifest file in the activity you are trying to start (Loading Activity)
Like this
<activity
android:name=".SplashActivity"
android:label="#string/app_name"
android:theme="#style/SplashTheme"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Also Add
Intent intent = new Intent(SplashActivity.this, MainActivity.class);