2016-11-03 44 views
0

我已經將反應本機從0.27更新爲0.35。將release.apk安裝到我的設備後,我只能用adb shell啓動它。Android無法找到應用程序的主要活動

安裝不會在手機上創建「桌面」圖標(是的,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> 

MainActivity:

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"; 
}} 

MainApplication:

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; 
    } 
} 
+0

選中此http://stackoverflow.com/a/ 15358205/2125612和http://stackoverflow.com/a/4776971/2125612 – Jickson

+1

謝謝!第二個幫了很多! – ddobby94

回答

2

就想通了:

的問題是在MainActivity標籤內。 您需要將MainActivity的內部內容與< intent-filter>標記分開。

前:

<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

1

你必須定義你的啓動活動在Android清單。

<activity android:name=".example.Main"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
+0

這是我的清單:' android:name =「android.intent.action.VIEW」/> =「android.intent.category.LAUNCHER」/> ' – ddobby94

+0

你能編輯你的maint文章嗎?和你的主要活動TY?如果您可以正確解析它,我們很容易爲您提供幫助。 – SamuelPS

相關問題