Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 在react native中构建签名版本APK的正确方法是什么?_React Native_Gradle - Fatal编程技术网

React native 在react native中构建签名版本APK的正确方法是什么?

React native 在react native中构建签名版本APK的正确方法是什么?,react-native,gradle,React Native,Gradle,我不太确定我所做的是否是正确的方法,或者我错过了一些步骤,或者我做的步骤太多了。构建APK的方法我从教程、论坛和示例中的各种发现中检索。再一次,我仍然不确定我建造它的方式 我在/android/app目录下有生成的密钥库文件 下面是我发现并尝试过的,但我不知道它们之间有什么不同: 第1步: cd安卓 >格雷德卢清洁酒店 >格雷德勒 第二步: >react native bundle--platform android--dev false--entry file index.js--bundl

我不太确定我所做的是否是正确的方法,或者我错过了一些步骤,或者我做的步骤太多了。构建APK的方法我从教程、论坛和示例中的各种发现中检索。再一次,我仍然不确定我建造它的方式

我在
/android/app
目录下有生成的密钥库文件 下面是我发现并尝试过的,但我不知道它们之间有什么不同:

第1步:

cd安卓 >格雷德卢清洁酒店 >格雷德勒 第二步:

>react native bundle--platform android--dev false--entry file index.js--bundle output android/app/src/main/assets/index.android.bundle
>cd安卓
>格雷德勒
第三步:

>react native bundle--platform android--dev false--entry file index.js--bundle output android/app/src/main/assets/index.android.bundle--assets dest android/app/src/main/res/
#转到“\android\app\src\main\res”并删除所有*drawable xxxx*和*raw*文件夹(如果存在)
>cd安卓
>gradlew Assembrelease-x BundreleaseJSandAssets
第4步:

>npx-jetify
>cd安卓
>格雷德卢清洁酒店
>格雷德勒
第五步:

#转到./android/app/src/main/assets/并删除'index.android.bundle'文件
>react native bundle--platform android--dev false--entry file index.js--bundle输出android/app/src/main/assets/index.android.bundle--assets dest android/app/src/main/res
>cd.\android\app\src\main\res&&if exist“drawable hdpi”rmdir“drawable hdpi”/q/s&&if exist“drawable mdpi”rmdir“drawable mdpi”rmdir“drawable xhdpi”/q/s&&if exist“drawable xxhdpi”rmdir“drawable xxhdpi”/q/s&&if exist“drawable xxxhdpi”rmdir“drawable xxxhdpi”/q/s&&if exist”rmdir“raw”rmdir“原始”/q/s
>cd….\..\..\..\android
>gradlew Assembrelease-x BundreleaseJSandAssets
另一方面,我还创建了自己的批处理文件,以使此生成成为APK。此文件将在运行项目根文件夹之前的一个文件夹中

构建本地版本。bat:

@echo关闭
::BatchGotAdmin
:-------------------------------------
REM-->检查权限
>nul 2>&1“%SYSTEMROOT%\system32\cacls.exe”“%SYSTEMROOT%\system32\config\system”
REM-->如果设置了错误标志,则我们没有管理员。
如果“%errorlevel%”NEQ“0”(
echo正在请求管理权限。。。
转到UACPrompt
)其他(转到转到管理)
:UACPrompt
echo Set UAC=CreateObject^(“Shell.Application”^)>%temp%\getadmin.vbs
设置参数=%*:“=”“”
echo UAC.ShellExecute“cmd.exe”、“/c%~s0%params%”、“,”runas“,1>>%temp%\getadmin.vbs”
%temp%\getadmin.vbs
删除“%temp%\getadmin.vbs”
退出/B
:gotAdmin
pushd“%CD%”
CD/D“%~dp0”
:--------------------------------------
如果未在\u子流程中定义(在\u子流程中设置cmd/k=y^&%0%*)&退出)
set-driveName=“%CD:~0,2%”
set-currentFolder=“%~dp0”
setlocal enableextensions enabledelayedexpansion
设置/A计数=1
集合列表=
CD%driveName%
回音===========================================
对于(*)中的/d%%d,请执行以下操作(
设置“listName=%%~f”
设置列表=%listName%%1
rem echo!listName!
回声!计数!^.%%~D
设置/a计数+=1
)
回音===========================================
:startAgain
设定选择=
set/p choice=输入列表中的目标文件夹以生成版本APK(例如targetfolder):
如果不是“%choice%”,则为(
如果存在%choice%(
设置选项=%choice%
CD%选择%
去表演
)
)
回显无效的目录名!
后藤星
:性能
echo脚本将在%choice%上启动要发布的生成目标APK。。。
超时/t 2/nobreak>nul
cd%currentFolder%%choice%^\android\app\src\main\assets
del“index.android.bundle”2>nul
cd%currentFolder%%选项%
调用react native bundle--platform android--dev false--entry file index.js--bundle output android/app/src/main/assets/index.android.bundle--assets dest android/app/src/main/res/
rem开始“%currentFolder%%choice%^\android\app\src\main\res
超时/t 2/nobreak>nul
cd%currentFolder%%choice%^\android\app\src\main\res
echo验证重复资源
如果存在“可绘制hdpi”rmdir“可绘制hdpi”/q/s 2>nul
如果存在“可绘制mdpi”rmdir“可绘制mdpi”/q/s 2>nul
如果存在“可绘制的xhdpi”rmdir“可绘制的xhdpi”/q/s 2>nul
如果存在“可绘制xxhdpi”rmdir“可绘制xxhdpi”/q/s 2>nul
如果存在“可绘制xxxhdpi”rmdir“可绘制xxxhdpi”/q/s 2>nul
如果存在“原始”rmdir“原始”/q/s 2>nul
cd%currentFolder%%choice%^\android
调用gradlew Assembrelease
cd%currentFolder%%选项%
:choiceOpt
设置/P answ=构建完成。是否要再次重建[Y/N]?
如果/I“%answ%”请求“Y”转到:性能
如果/I“%answ%”请求“N”转到:仅退出
后藤:精选
:只需退出
回声退出
超时/t 2/nobreak>nul
出口

而在
\android\app\build\outputs\APK\release
上创建的这个APK就是我们将要上传到Playstore进行验证的APK?

因此,最后请看,您希望将签名的APK/捆绑包上传到您的Playstore。要做到这一点,正如你所提到的,所有步骤最后都执行相同的操作。创建已签名的APK:

以下步骤最适合您遵循:

1.创建一个更新的js包,因为它包含您的最新代码。这样做是为了更新react本机代码的包。请在
android/app/src/main/assets
目录中检查您的捆绑包文件是否命名为
index.android.bundle
,或者仅命名为
index.bundle

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
2.在Android X之后,您希望迁移所有与Android X兼容的依赖项。 在本机目录中,执行以下操作:

纱线添加喷射器
npm i喷射器
然后

3.完成此操作后,导航到
npx jetify  
./gradlew clean