X-dea / flutter_vpn

Plugin to access VPN service for Flutter | Flutter 的 VPN 插件
GNU Lesser General Public License v3.0
350 stars 126 forks source link

App Lunch Failed after installing Release APK #31

Closed bubundas17 closed 4 years ago

bubundas17 commented 4 years ago

Hi, I am facing a problem when building release apk.

Whenever I am trying to install release apk generated by running "flutter build apk --release", It crushes before starting.

But the apk generated from "flutter run --release" seems to work just fine.

xiyulangzi commented 4 years ago

@bubundas17 is your message as below? I met similar issue with below error message, the debug version works fine but release version has this error. ======log from logcat ======= Abort message: 'thread.cc:2090] No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "org.strongswan.android.logic.CharonVpnService$BuilderAdapter" on path: DexPathList[[zip.......................

bubundas17 commented 4 years ago

Yap, this is exactly the same problem I am also facing.

On Fri, 10 Jan, 2020, 11:37 PM xiyulangzi, notifications@github.com wrote:

@bubundas17 https://github.com/bubundas17 is your message as below? I met similar issue with below error message, the debug version works fine but release version has this error. ======log from logcat ======= Abort message: 'thread.cc:2090] No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "org.strongswan.android.logic.CharonVpnService$BuilderAdapter" on path: DexPathList[[zip.......................

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/X-dea/Flutter-VPN/issues/31?email_source=notifications&email_token=AGIQBURQQNFVZUYSACKHIV3Q5C2PVA5CNFSM4KB3UOC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIUXZZI#issuecomment-573144293, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGIQBUSOR5X75GWT4ENHOF3Q5C2PVANCNFSM4KB3UOCQ .

ctrysbita commented 4 years ago

Maybe you enabled Android R8 compiler which will minimize the code and delete unused classes during compilation. However, BuilderAdapter is a class for JNI invocation and not used in java layer, which may be deleted by compiler. Please try to disable minimization. Thanks.

xiyulangzi commented 4 years ago

if disable R8, then new error will popup:

https://github.com/dscoppelletti/spaceship/issues/8 the solution is enable R8, so we have a deadloop here

ctrysbita commented 4 years ago

Or try to disable minimazation ? Or you can try to use rules to keep org.strongswan.android.* ?

xiyulangzi commented 4 years ago

keep helps, issue resolved, my android\app\proguard-rules.pro like below

# way to debug R8 code shrinking
# https://developer.android.com/studio/build/shrink-code#keep-code

# enable this line to show classes removed by shrinking in usage.txt file
# -printusage ./usage.txt

# keep class removed wrongly by R8, if don't have this line, app crash during startup 
# Abort message: 'thread.cc:2090] No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "org.strongswan.android.logic.CharonVpnService$BuilderAdapter" on path: DexPathList[[zip.......................

-keep class org.strongswan.**  { *; }
bubundas17 commented 4 years ago

@xiyulangzi It seems to solve the issue. Thanks! issue closed.