2016-05-31 15 views
5

私は自分の質問を詳しく解説し、詳細を示すのに十分な情報を提供するよう努力します。まず 、貼り付けるエラーログ(FATAL EXCEPTION: AsyncTask #1 java.lang.RuntimeException: An error occured while executing doInBackground()):リアクションネイティブ既存のAndroidアプリとの統合

FATAL EXCEPTION: AsyncTask #1 java.lang.RuntimeException: An error occured while executing doInBackground() 
                          at android.os.AsyncTask$3.done(AsyncTask.java:299) 
                          at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) 
                          at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 
                          at java.util.concurrent.FutureTask.run(FutureTask.java:239) 
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                          at java.lang.Thread.run(Thread.java:841) 
                         Caused by: java.lang.IllegalAccessError: tried to access method android.support.v4.net.ConnectivityManagerCompat.<init>:(Lcom/facebook/react/bridge/ReactApplicationContext;)V from class com.facebook.react.modules.netinfo.NetInfoModule 
                          at com.facebook.react.modules.netinfo.NetInfoModule.<init>(NetInfoModule.java:55) 
                          at com.facebook.react.shell.MainReactPackage.createNativeModules(MainReactPackage.java:67) 
                          at com.facebook.react.ReactInstanceManagerImpl.processPackage(ReactInstanceManagerImpl.java:751) 
                          at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:688) 
                          at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:84) 
                          at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:177) 
                          at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:162) 
                          at android.os.AsyncTask$2.call(AsyncTask.java:287) 
                          at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)  
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)  
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)  
                          at java.lang.Thread.run(Thread.java:841) 

マイプロジェクト構造:

project structrue

android part

アンドロイド依存関係:

dependencies { 
    ... 
    compile 'com.facebook.react:react-native:0.20.0' 
} 

のAndroidManifest.xml:

<application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     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> 
     <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> 
    </application> 
    <uses-permission android:name="android.permission.INTERNET"/> 

MainActivity.java:

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler { 

    private ReactRootView mReactRootView; 
    private ReactInstanceManager mReactInstanceManager; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     mReactRootView = new ReactRootView(this); 
     mReactInstanceManager = ReactInstanceManager.builder() 
       .setApplication(getApplication()) 
       .setBundleAssetName("index.android.bundle") 
       .setJSMainModuleName("index.android") 
       .addPackage(new MainReactPackage()) 
       .setUseDeveloperSupport(BuildConfig.DEBUG) 
       .setInitialLifecycleState(LifecycleState.RESUMED) 
       .build(); 
     mReactRootView.startReactApplication(mReactInstanceManager, "AndroidToRn03", null); 

     setContentView(mReactRootView); 
    } 
    ... 
} 

package.json:その後、

{ 
    "name": "androidtorn03", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.android.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "start": "node node_modules/react-native/local-cli/cli.js start" 
    }, 
    "author": "", 
    "license": "ISC", 
    "dependencies": { 
    "react-native": "^0.26.2" 
    } 
} 

、index.android.js:

import React from 'react'; 
import { 
    AppRegistry, 
    StyleSheet, 
    Text, 
    View 
} from 'react-native'; 

class AndroidToRn03 extends React.Component { 
    render() { 
    return (
     <View style={styles.container}> 
     <Text style={styles.hello}>React Native....</Text> 
     </View> 
    ) 
    } 
} 
var styles = StyleSheet.create({ 
    container: { 
    flex: 1, 
    justifyContent: 'center', 
    }, 
    hello: { 
    fontSize: 20, 
    textAlign: 'center', 
    margin: 10, 
    }, 
}); 

AppRegistry.registerComponent('AndroidToRn03',() => AndroidToRn03); 

I何度も試したimesはdocs on facebook's websiteによると、すべてが失敗し、アプリは開封時にフラッシュバックします。 私はあなたの助けが必要です!私を助けるのに少し時間がかかりますか?

+0

を私は同じエラーを持っている:( –

+0

@herdotageあなたがこの問題を解決することができましたか? – hannanessay

答えて

0

変更ファイルapp/build.gradle依存関係:

compile 'com.android.support:appcompat-v7:23.0.1'

関連する問題