我无法为运行Jellybean 4.2.2的Galaxy S4运行run-as(或ndk-gdb)。
~ $ adb shell
shell@android:/ $ run-as a.b.c ls
run-as: Package 'a.b.c' is unknown
这个问题对于ICS前设备有多个答案,但这些似乎已在ICS中得到修复。
更新 - 2013年8月:在最初出现在带有Jellybean 4.2.2的Galaxy S4之后,现在似乎是所有4.3设备上的运行问题。请参阅此Android bug。
查看已确认的Android问题here。
更新 - 2013年11月:Google发布了修复run-in Android 4.4的patches。
答案 0 :(得分:13)
通过将此添加到活动中找到成功:
private void startGdbServer() {
try {
new ProcessBuilder()
.command(getFilesDir().getParent() + "/lib/gdbserver", "tcp:5039", "--attach" ,"" + android.os.Process.myPid())
.redirectErrorStream(true)
.start();
} catch (IOException e) {
Log.e(TAG, "IOException failed to start gdbserver");
}
}
然后我将startGdbServer包装在Android服务中并更新ndk-gdb脚本以启动服务器而不是run-as命令。
这是明显的补充:
<service android:enabled="true" android:name="com.apportable.activity.GdbServerService"
android:label="@string/app_name" android:icon="@drawable/icon">
<intent-filter >
<action android:name="apportable.FoundationTests.GdbServerService" />
</intent-filter>
</service>
以下是相关的ndk-gdb更改(在python中):
remote_gdbserver = '/data/data/' + env['APPLICATION_IDENTIFIER'] + '/lib/gdbserver'
print "Attaching to pid " + pid
# Android 4.2 requires the --user 0 option. Earlier versions cannot have it
results = env.Execute([env['ADB'], 'shell', 'am'])
if "--user" in results:
user_option = "--user 0"
else:
user_option = ""
adb.AsyncShell(env, 'am startservice ' + user_option + ' -a ' + env['APPLICATION_IDENTIFIER'] + '.GdbServerService --es gdbserver_name ' + remote_gdbserver + ' --ei gdbserver_port ' + str(env['ANDROID_REMOTE_DEBUG_PORT']))
# HACK: magic number. ensure the gdb server is actually up and running
time.sleep(2) # 1 is usually enough, but not always, like after reboot or with heavy system load
adb.Forward(env, env['ANDROID_LOCAL_DEBUG_PORT'], env['ANDROID_REMOTE_DEBUG_PORT'])
adb.Pull(env, process_path, '/system/bin/app_process')
setup_path = '"' + setup_path + '"'
if env['CGDB'] is not None:
cmd = [env['CGDB'], '-d', env['GDB'], '--', '-x', setup_path]
else:
cmd = [env['GDB'], '-x', setup_path]
env.RunCommand(cmd)
答案 1 :(得分:0)
最终修复我的Nexus 7的一件事就是安装不同的ADB驱动程序。我也重新刷新了设备(虽然我不确定这是不是确实修复了它)。正如另一个答案(我的)中提到的那样,需要生根 - 事实上,它对我的情况也没有帮助。
答案 2 :(得分:0)
就我而言,这是核心应用程序的问题:
shell@android:/ $ run-as com.android.phone transfer_bugreport ls
run-as: Package 'com.android.phone' is unknown
AndroidManifest.xml
<maninfest>
coreApp="true"
/data/system/packages.list
中包含run-as
public class SwipeDismissTouchListener implements View.OnTouchListener {
private int mSlop;
private int mMinFlingVelocity;
private int mMaxFlingVelocity;
private long mAnimationTime;
// Fixed properties
private CustomEditTextWithCheckbox mView;
private DismissCallbacks mCallbacks;
private int mViewWidth = 1; // 1 and not 0 to prevent dividing by zero
// Transient properties
private float mDownX;
private float mDownY;
private boolean mSwiping;
private int mSwipingSlop;
private VelocityTracker mVelocityTracker;
private float mTranslationX;
public interface DismissCallbacks {
boolean canDismiss();
void onDismiss(View view);
}
public SwipeDismissTouchListener(CustomEditTextWithCheckbox view, DismissCallbacks callbacks) {
ViewConfiguration vc = ViewConfiguration.get(view.getContext());
mSlop = vc.getScaledTouchSlop();
mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
mAnimationTime = view.getContext().getResources().getInteger(
android.R.integer.config_shortAnimTime);
mView = view;
mCallbacks = callbacks;
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// offset because the view is translated during swipe
motionEvent.offsetLocation(mTranslationX, 0);
if (mViewWidth < 2) {
mViewWidth = mView.getWidth();
}
switch (motionEvent.getActionMasked()) {
case MotionEvent.ACTION_DOWN: {
// TODO: ensure this is a finger, and set a flag
mDownX = motionEvent.getRawX();
mDownY = motionEvent.getRawY();
if (mCallbacks.canDismiss()) {
mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(motionEvent);
}
return false;
}
case MotionEvent.ACTION_UP: {
if (mVelocityTracker == null) {
break;
}
float deltaX = motionEvent.getRawX() - mDownX;
mVelocityTracker.addMovement(motionEvent);
mVelocityTracker.computeCurrentVelocity(1000);
float velocityX = mVelocityTracker.getXVelocity();
float absVelocityX = Math.abs(velocityX);
float absVelocityY = Math.abs(mVelocityTracker.getYVelocity());
boolean dismissRight = false;
if (Math.abs(deltaX) > mViewWidth / 2 && mSwiping) {
dismissRight = deltaX > 0;
} else if (mMinFlingVelocity <= absVelocityX && absVelocityX <= mMaxFlingVelocity
&& absVelocityY < absVelocityX
&& absVelocityY < absVelocityX && mSwiping) {
dismissRight = mVelocityTracker.getXVelocity() > 0;
}
if (dismissRight) {
mView.onSwipeRight();
} else if (mSwiping) {
mView.onSwipeLeft();
}
mVelocityTracker.recycle();
mVelocityTracker = null;
mTranslationX = 0;
mDownX = 0;
mDownY = 0;
mSwiping = false;
break;
}
case MotionEvent.ACTION_CANCEL: {
if (mVelocityTracker == null) {
break;
}
mVelocityTracker.recycle();
mVelocityTracker = null;
mTranslationX = 0;
mDownX = 0;
mDownY = 0;
mSwiping = false;
break;
}
case MotionEvent.ACTION_MOVE: {
if (mVelocityTracker == null) {
break;
}
mVelocityTracker.addMovement(motionEvent);
float deltaX = motionEvent.getRawX() - mDownX;
float deltaY = motionEvent.getRawY() - mDownY;
if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
mSwiping = true;
mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop);
mView.getParent().requestDisallowInterceptTouchEvent(true);
MotionEvent cancelEvent = MotionEvent.obtain(motionEvent);
cancelEvent.setAction(MotionEvent.ACTION_CANCEL |
(motionEvent.getActionIndex() <<
MotionEvent.ACTION_POINTER_INDEX_SHIFT));
mView.onTouchEvent(cancelEvent);
cancelEvent.recycle();
}
break;
}
}
return false;
}
}
的{{1}}被排除在rm /usr/local/bin/npm
之外的sudo ln -s /usr/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
。
答案 3 :(得分:-1)
Nexus 7的最新版本存在一个已知问题。只需降级到4.2(或在没有迷你更新的情况下获得4.3),你应该没问题。这里有一个关于它的讨论: