【问题标题】:how to push additional required files to the app directory?如何将其他需要的文件推送到应用程序目录?
【发布时间】:2019-01-12 21:50:11
【问题描述】:

我是 Android 开发的新手,我在谷歌上搜索这个答案,但很多事情只是如何将音乐和内容上传到您的设备。

一些信息

我有一个编译成 c++ 的应用程序,当我使用 gradlew installDebug 推送它时,它将在设备上运行。问题是我想添加一些相当大的依赖项,文件空间大约为 1G。

我注意到当我尝试使用 adb 推送文件时,我根本无法写入 /data/app/app-name 目录。

有没有办法在安装过程中将它们移到那里,或者应该如何处理?请记住,我的应用程序是用 C++ 编写的,并使用 ndk-builder 进行交叉编译。

简而言之:

理想情况下,我希望用户能够在安装应用程序时拥有他需要的所有文件。我怎么能/应该这样做?

【问题讨论】:

    标签: android c++ c++14 adb file-transfer


    【解决方案1】:

    所以答案是您可以在安装时将文件添加到 /data/app/res/ 文件夹,但我认为它必须很小,小于 100MB。

    您可以将用户权限标记到manafest并将数据存储在/sdcard/Yourcreatedfolder中,然后像C中的任何其他目录一样访问它。

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="pvallet.com.github.hello_sdl2">
    
    
        <application
            android:allowBackup="true"
            android:label="@string/app_name"
            android:icon="@mipmap/ic_launcher"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"    
        android:theme="@style/AppTheme"    
    
    
        >
            <activity
                android:name=".HelloSDL2Activity"
            android:screenOrientation="landscape"
                android:windowSoftInputMode="stateVisible|adjustResize"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
                android:label="@string/app_name"
                android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    
    
            >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
               <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"   />
    </manifest>
    

    【讨论】:

      猜你喜欢
      • 2012-12-26
      • 2017-06-16
      • 1970-01-01
      • 2019-05-15
      • 1970-01-01
      • 2020-11-23
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      相关资源
      最近更新 更多