Android找不到应用程序的mainactivity

标签 android react-native

我已经将 react-native 从 0.27 更新到 0.35。将 release.apk 安装到我的设备后,我只能使用 adb shell 启动它。

安装不会在手机上创建“桌面”图标(是的,png-s 放置正确),并且在设置/应用程序管理器中,即使我可以找到我的应用程序和所有关于它的信息,我无法通过它的 mainActivity 启动它。

有什么想法吗?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="my.pckg.name"
android:versionCode="1"
android:versionName="1.0">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>

<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>


<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=".MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
                   android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:launchMode="singleTop">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />  
            <data android:scheme="http"
                  android:host="my.website.for.DeepLink"
                  android:pathPrefix="/#/register_login/status=successful" />          
        </intent-filter>          
    </activity>
</application></manifest>

主要 Activity :

package my.pckg.name;
import com.facebook.react.ReactActivity;
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 "pckgName";
}}

主要应用:

package my.pckg.name;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
//... other stuff
import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication    {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
  return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      //.... other stuff
  );
}
};

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

最佳答案

刚想通了:

问题出在 mainActivity 标签内。 您需要使用 标记分隔 MainActivity 的内部内容。

之前:

  <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />  
        <data android:scheme="http"
              android:host="my.website.for.DeepLink"
              android:pathPrefix="/#/register_login/status=successful" />          
    </intent-filter>       

(工作的)之后:

   <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="http"
              android:host="my.website.for.DeepLink"
              android:pathPrefix="/#/register_login/status=successful" />          
    </intent-filter>       

更多信息:https://developer.android.com/guide/components/intents-filters.html#imatch

关于Android找不到应用程序的mainactivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40405020/

相关文章:

android - 使用 django-rest-auth 在 Android 中登录 Google

java.lang.IndexOutOfBoundsException : Invalid index 0, 大小为 0

android - 如何在没有远程调试的情况下使用 Android 上的 React Native 查看控制台日志? (genymotion)

android - ENOENT : no such file or directory, 打开 'android/app/src/main/assets/index.android.bundle'

react-native - React Native : Why does stylesheet. 创建带有数字而不是样式的返回对象?

android - 需要一个这样的旋转器

android - Gradle -使用口味

java - Android如何解析XHTML

xamarin - 是否可以在构建的应用程序中查看 React Native 源代码?

ios - fetch() 在 react-native (iOS) 上执行 GET 而不是 POST