Termux源碼匯入遇到的問題

來源:互聯網
上載者:User

標籤:

  今天看到一個有意思的項目--Termux,然後就把源碼搞下來了。但是匯入到Android Studio裡編譯啟動並執行時候報錯了!

java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.termux/files/instant-run/dex/slice-support-annotations-23.3.0_22f92d96560c582f4641cd755383bea196ee8431-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-internal_impl-23.3.0_3144189e496bc31081b68ab24955a911f82ed66b-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.3.0_df3704b01aa38b8a7f534fb8d2a80f23e576bcf8-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-com.android.support-support-v4-23.3.0_2a9351bfabee659f69965f79a9f0f22c2f914d2e-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.3.0_8d8d2297d7a78b982c4922fea66c068a8e28fd02-classes.dex", dex file "/data/data/com.termux/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.3.0_16904b6df415103ab22dadb9dcc59453ef887292-classes.dex"],nativeLibraryDirectories=[/data/app/com.termux-1/lib/x86, /vendor/lib, /system/lib]]] couldn‘t find "libtermux.so"  at java.lang.Runtime.loadLibrary(Runtime.java:367)  at java.lang.System.loadLibrary(System.java:1076)  at com.termux.terminal.JNI.<clinit>(JNI.java:9)  at com.termux.terminal.TerminalSession.initializeEmulator(TerminalSession.java:175)  at com.termux.terminal.TerminalSession.updateSize(TerminalSession.java:151)  at com.termux.view.TerminalView.updateSize(TerminalView.java:828)  at com.termux.view.TerminalView.attachSession(TerminalView.java:227)  at com.termux.app.TermuxActivity.switchToSession(TermuxActivity.java:584)  at com.termux.app.TermuxActivity.addNewSession(TermuxActivity.java:577)  at com.termux.app.TermuxActivity$11.run(TermuxActivity.java:479)  at com.termux.app.TermuxInstaller.setupIfNeeded(TermuxInstaller.java:72)  at com.termux.app.TermuxActivity.onServiceConnected(TermuxActivity.java:463)  at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1223)  at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1240)  at android.os.Handler.handleCallback(Handler.java:739)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

  (其實現在我的內心是非常高興的,原因你不懂。。)

  然後我這個小白那是好一通查資料,終於明白了這個項目中人家在gradle檔案中屏蔽掉了預設的jni編譯產生過程

    sourceSets {        main {            jni.srcDirs = []        }    }

  然後就需要手動使用ndk-build命令先編譯好so檔案然後才可以構建工程。我不想那麼麻煩,依然想用gradle來完成,結果又是一通查。

  解決方案如下:

  首先把上面那段代碼刪掉,然後在defaultConfig中添加如下代碼:

        ndk{            moduleName "libtermux"            cFlags "-std=c11 -Wall -Wextra -Os -fno-stack-protector"        }

  問題就愉快地解決啦。

  注意!一定要有cFlags的配置,要不然會報這個錯:

Error:(131, 9) error: ‘for‘ loop initial declarations are only allowed in C99 or C11 mode

Termux源碼匯入遇到的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.