我有一些应用程序需要安装在系统目录下
。我见过几种使用adb命令的方法。我认为这必须使用pc上的adb外壳和usb电缆来完成。但是,应用程序是否可以在不需要pc的情况下将自身从
数据
复制到系统
目录?
据我所知,我们可以使用
Runtime
在android应用程序中运行命令。所以,我尝试了onCreate
中的这段代码,但是它没有复制. apk文件。这是代码:
boolean isSystemApp = (getApplicationInfo().flags
& (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0;
if (!isSystemApp) {
Toast.makeText(getApplicationContext (), "not system app", Toast.LENGTH_LONG).show();
try {
String [] commandsOldVersions = {"adb shell\n", "su\n", "mount -o rw,remount /system\n",
"adb push eyedetection.apk /sdcard/\n", "adb shell\n","su cd /sdcard\n"
, "mv eyedetection.apk /system/app\n","su chmod 644/system/app/eyedetection.apk\n" };
String [] commandsNewVersions = {"adb shell\n", "su\n", "mount -o rw,remount /system\n",
"adb push eyedetection.apk /sdcard/\n", "adb shell\n","su cd /sdcard\n"
, "mv eyedetection.apk /system/priv-app\n", "su chmod 644/system/priv-app/eyedetection.apk\n" };
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
// for 4.3 and higher versions, execute the following line (because they've changed their system files hierarchies):
Process process = Runtime.getRuntime().exec(commandsNewVersions);
BufferedReader br= new BufferedReader(new InputStreamReader(process.getInputStream()));
Log.i("cmd", br.readLine());
}//end if
else {
//for older version, execute this line instead
Process process= Runtime.getRuntime().exec(commandsOldVersions);
BufferedReader br= new BufferedReader(new InputStreamReader(process.getInputStream()));
Log.i("cmd", br.readLine());
}//end else.
Runtime.getRuntime().exec("adb reboot");
}//end try.
catch (IOException e) {
Log.i("eyedetection", "error in executing adb commands");
}//end catch.
}//end if the app is not system app.
else {
Toast.makeText(getApplicationContext (), "It's system app", Toast.LENGTH_LONG).show();
}
应用程序不会崩溃,但我在logcat中得到这些行:
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve virtual method 143: Landroid/app/Notification$Builder;.setPriority (I)Landroid/app/Notification$Builder;
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x6e at 0x0042
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection I/dalvikvm: Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.os.b
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve virtual method 142: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x6e at 0x00ce
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection E/dalvikvm: Could not find class 'android.app.Notification$BigTextStyle', referenced from method com.google.android.gms.common.os.b
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve new-instance 42 (Landroid/app/Notification$BigTextStyle;) in Lcom/google/android/gms/common/os;
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x22 at 0x00d7
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection D/dalvikvm: DexOpt: couldn't find field Landroid/app/Notification;.extras
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve instance field 10
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x54 at 0x00ed
03-24 22:28:37.661 22576-22576/com.project.android.eyedetection D/dalvikvm: DexOpt: unable to opt direct call 0x0084 at 0x4c in Lcom/google/android/gms/common/os;.b
03-24 22:28:37.669 22576-22576/com.project.android.eyedetection D/dalvikvm: DexOpt: unable to opt direct call 0x0084 at 0xd9 in Lcom/google/android/gms/common/os;.b
03-24 22:28:37.669 22576-22576/com.project.android.eyedetection E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.ou.a
03-24 22:28:37.669 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve check-cast 30 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/ou;
03-24 22:28:37.669 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x1f at 0x0010
03-24 22:28:37.669 22576-22576/com.project.android.eyedetection I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.ou.a
03-24 22:28:37.669 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve virtual method 430: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
03-24 22:28:37.669 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x6e at 0x000d
03-24 22:28:37.677 22576-22576/com.project.android.eyedetection E/dalvikvm: Could not find class 'android.os.UserManager', referenced from method com.google.android.gms.common.ou.p
03-24 22:28:37.677 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve check-cast 235 (Landroid/os/UserManager;) in Lcom/google/android/gms/common/ou;
03-24 22:28:37.677 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x1f at 0x000e
03-24 22:28:37.677 22576-22576/com.project.android.eyedetection D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_64_BIT_ABIS
03-24 22:28:37.677 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve static field 119 (SUPPORTED_64_BIT_ABIS) in Landroid/os/Build;
03-24 22:28:37.677 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x62 at 0x000d
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_ABIS
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve static field 120 (SUPPORTED_ABIS) in Landroid/os/Build;
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x62 at 0x0008
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_32_BIT_ABIS
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve static field 118 (SUPPORTED_32_BIT_ABIS) in Landroid/os/Build;
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection D/dalvikvm: VFY: replacing opcode 0x62 at 0x0008
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_64_BIT_ABIS
03-24 22:28:37.685 22576-22576/com.project.android.eyedetection W/dalvikvm: VFY: unable to resolve static field 119 (SUPPORTED_64_BIT_ABIS) in Landroid/os/Build;
还有这些行:
03-24 22:29:54.388 23305-23305/com.project.android.eyedetection E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
03-24 22:29:54.388 23305-23305/com.project.android.eyedetection E/GMPM: Scheduler not set. Not logging error/warn.
03-24 22:29:54.403 23305-23335/com.project.android.eyedetection E/GMPM: Uploading is not possible. App measurement disabled
我无法从日志中找出问题所在。为什么代码不起作用?是否可以让应用程序将自身复制到根设备上的另一个文件夹,或者我们必须使用
usb
电缆?
“adb xxx”命令只能在PC外壳中使用,不能在Android/Linux外壳中使用<也就是说,您应该使用
运行时。getRuntime()。执行(“重新启动”)
而不是
有没有一种方法可以在非根android设备上使用系统签名的应用程序进行系统范围的网络过滤? 类似于在根设备中使用iptables binary的应用程序。
我正在使用Windows8。我正在尝试在设备上运行应用程序。找不到我的设备,设备USB调试已启用。此外,我已经安装了相同的驱动程序使用管理我也安装了谷歌USB驱动程序包。但仍然找不到该设备。 拜托,有人能帮忙吗
我正在开发一个android应用程序。我想从扎根设备中保存我的应用程序。我成功地限制了我的应用程序与根设备,但一个根设备有magisk应用程序,所以在这个magis应用程序的帮助下,用户可以打开我的应用程序在根设备也。有人能帮我吗?提前谢了。 我的代码是 私有静态布尔checkRootMethod1(){String buildTags=build.tags;return buildTags!=n
我试图建立一个基于libSuperuser的应用程序。我的设备是根,但我有两个问题: 1) 在出口我的apk后,出于某种原因,它正在索取证书。我需要导出对根设备没有意义的应用程序签名。如果设备已根目录,为什么需要签名? 2) 运行应用程序时,我检查应用程序是否具有调用Shell的root权限。苏。available()在libsuperuser中可用,返回“false”。这意味着该应用程序没有ro
我正在尝试使用将应用程序容器中的文件夹复制到本地Windows文件夹。该设备运行的是Android5.1.1,没有根。 以下方法不起作用: 方法1 错误:找不到设备 cp:/data/data/droidsample.droidsample/files/metrolog/metrologs是一个目录(未复制)。 这也是行不通的。 方法5 cp:/data/data/droidsample.droi
我正试图在Android设备上运行我的应用程序:AmazonFireTV。 此构建可能会更快,请考虑使用Gradle守护进程:https://docs.Gradle.org/2.14.1/userguide/gradle_daemon.html Running/users/xxxx/library/android/sdk//platform-tools/adb-s 68.128.177.159:5