我正在尝试生成我的第一个反应原生应用程序的签名apk我按照official site of react native
中的步骤我尝试了这个命令cd android && gradlew assembleRelease
,并成功生成了apk。
但是当我尝试使用cd android && gradlew installRelease
在我的真实设备上测试此apk时,应用程序崩溃了,尽管它在genymotion模拟器上按预期工作。
我错过了什么吗?
感谢任何帮助。 提前致谢
更新
我无法在我的设备上进行调试,因为我总是看到红色屏幕显示Unable to download JS bundle
,尽管我已经完成了官方网站上提到的关于running on the device的所有内容
logcat的:
03-15 16:23:13.504 24331-24331/com.kora E/ViewRootImpl: sendUserActionEvent() mView == null
03-15 16:23:13.939 24331-24359/com.kora E/unknown:React: Unable to download JS bundle
java.net.ConnectException: failed to connect to /192.168.1.6 (port 8081) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:223)
at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:843)
at com.squareup.okhttp.internal.Platform$Android.connectSocket(Platform.java:190)
at com.squareup.okhttp.Connection.connectSocket(Connection.java:196)
at com.squareup.okhttp.Connection.connect(Connection.java:172)
at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
at com.squareup.okhttp.Call.getResponse(Call.java:267)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
at com.squareup.okhttp.Call.access$100(Call.java:34)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:208)
at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:843)
at com.squareup.okhttp.internal.Platform$Android.connectSocket(Platform.java:190)
at com.squareup.okhttp.Connection.connectSocket(Connection.java:196)
at com.squareup.okhttp.Connection.connect(Connection.java:172)
at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
at com.squareup.okhttp.Call.getResponse(Call.java:267)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
at com.squareup.okhttp.Call.access$100(Call.java:34)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
03-15 16:23:13.944 24331-24331/com.kora E/ViewRootImpl: sendUserActionEvent() mView == null
答案 0 :(得分:0)
感谢@G。 Hamaide为他的answer,它对我有用,但在buildTypes
app/build.gradle
中添加了一个,正如官方文档中提到的那样添加此行signingConfig signingConfigs.release
。
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
那加上什么是@G。哈马德在上面提到的答案中提到过。
改变这个:
def enableProguardInReleaseBuilds = true
到此:
def enableProguardInReleaseBuilds = false
然后再次运行步骤为您创建APK。