2017-03-09 83 views
0

我試圖在發佈模式下運行我的反應原生應用程序。 APK是按照文檔簽名的,並且第一次運行正常(在模擬器和實際設備中)。React Native簽名版本構建,但無法啓動

儘管一些更新(添加庫,改變gradle這個配置,開發更多的代碼)釋放安裝不工作後:

  • 在調試模式下,所有工程確定(建設,模擬器和真正的手機)
  • 在釋放模式在啓動(模擬器和真正的手機)

在我看到下面的錯誤日誌中建立正常,但應用程序崩潰

這裏是我的版本文件夾下的AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     package="com.myfakeappname"> 

     <application 
     android:name=".MainApplication" 
     > 

     </application> 
</manifest> 

編輯:添加proguard-rules.pro

# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 
# You can edit the include path and order by changing the proguardFiles 
# directive in build.gradle. 
# 
# For more details, see 
# http://developer.android.com/guide/developing/tools/proguard.html 

# Add any project specific keep options here: 

# If your project uses WebView with JS, uncomment the following 
# and specify the fully qualified class name to the JavaScript interface 
# class: 
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { 
# public *; 
#} 

# Disabling obfuscation is useful if you collect stack traces from production crashes 
# (unless you are using a system that supports de-obfuscate the stack traces). 
-dontobfuscate 

# React Native 

# Keep our interfaces so they can be used by other ProGuard rules. 
# See http://sourceforge.net/p/proguard/bugs/466/ 
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 

# Do not strip any method/class that is annotated with @DoNotStrip 
-keep @com.facebook.proguard.annotations.DoNotStrip class * 
-keep @com.facebook.common.internal.DoNotStrip class * 
-keepclassmembers class * { 
    @com.facebook.proguard.annotations.DoNotStrip *; 
    @com.facebook.common.internal.DoNotStrip *; 
} 

-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 
    void set*(***); 
    *** get*(); 
} 

-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 
-keep class * extends com.facebook.react.bridge.NativeModule { *; } 
-keepclassmembers,includedescriptorclasses class * { native <methods>; } 
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; } 
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; } 
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; } 

-dontwarn com.facebook.react.** 

# okhttp 

-keepattributes Signature 
-keepattributes *Annotation* 
-keep class okhttp3.** { *; } 
-keep interface okhttp3.** { *; } 
-dontwarn okhttp3.** 

# okio 

-keep class sun.misc.Unsafe { *; } 
-dontwarn java.nio.file.* 
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 
-dontwarn okio.** 
+1

請確保您在java/com/myfakeappname /(相對於AndroidManifest)中有一個MainApplication,並且在頂部有: package com.myfakeappname; – atlanteh

回答

0

最有可能你啓用ProGuard,並將一些類被混淆,使他們不在運行時發現。

嘗試在發佈配置中禁用它,然後重試。如果你需要,發佈你的proguard.properties文件。

+0

禁用proguard確實有效。我要用proguar-rules.pro編輯這個問題 – stilllife

+0

你發佈的帖子看起來不錯。這些是ReactNative的基礎。你有沒有其他模塊可以將規則添加到proguard配置中? – sfratini