- @echo off
- echo.
- if not "%~1"=="" ( if exist %1 goto start else goto noexist ) else goto usage
-
- :noexist
- echo 目录:%~1 不存在!请确认是否输错!
- goto end
-
- :usage
- echo 用法:%0 目录名 jid
- goto end
-
- :start
-
- set iserror=0
- sed -i -e "/<\/application>/r advert\adall.txt" -e "s/<\/application>//" %1\AndroidManifest.xml
- if not %errorlevel%==0 ( set iserror=%errorlevel% )
-
- if not "%2"=="" ( sed -i "s/zy2860634b9e5742b2b43acc2e0a22b5f8/%2/g" %1\AndroidManifest.xml )
- if not %errorlevel%==0 ( set iserror=%errorlevel% )
-
- REM xcopy advert\SDKALL\* %1\ /Y /E /Q >nul
- if not %errorlevel%==0 ( set iserror=%errorlevel% )
-
- ::启动项包名
- for /f %%i in ('sed -n "/android.intent.action.MAIN/=" %1\AndroidManifest.xml') do (
- set n=%%i
- )
- set /a m=n-3
- sed -r "%m%,%n%!d; /activity android:label/!d; s/.*android:name=.([^\"]+)\".*/\1/" %1\AndroidManifest.xml > %temp%\1.dat
- set /p str=<%temp%\1.dat
- echo %str%
- sed -i "s/com.example.andrpush_mytest_3_7_sdk_wulog_cgdemo.MainActivity/%str%/g" %1\AndroidManifest.xml
-
-
- ::echo %versionCode%
- for /f "tokens=5 delims== " %%i in ('type %1\AndroidManifest.xml^| findstr "android:versionName"') do (
- set versionName=%%~i
- goto :next1
- )
- :next1
- ::echo %versionName%
-
- for /f "tokens=3 delims== " %%i in ('type %1\AndroidManifest.xml^| findstr "android:versionCode"') do (
- set versionCode=%%~i
- goto :next2
- )
- :next2
-
- for /f "tokens=3 delims=<>" %%i in ('type %1\res\values\strings.xml^| findstr "app_name"') do (
- set appname=%%i
- goto :next3
- )
- :next3
- echo,%appname%
-
- echo 版本号:%versionCode%-----------------版本名: %versionName% > %1\Package.txt
- ::sed -i "s#android:versionCode=\".*\"#android:versionCode=\"%newCode%\"#" %1\AndroidManifest.xml
-
- :end
复制代码 我测试的是这个代码
没有发现报错
执行的命令如下:复制代码 |