LOCAL_JACK_ENABLED := disabled
fatal: unable to auto-detect email address (got ‘jun@jun.(none)’)
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
方法一:修改编译文件,使之支持4.1 https://www.cnblogs.com/blowing-in-the-wind/p/5960375.html
gedit build/core/main.mk
add ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 4.1))
方法二: 降低make版本(编译不过) https://blog.csdn.net/victory08/article/details/51593994
下载对应版本的make ftp://ftp.gnu.org/gnu/make/
解压 tar -xvf make-3.81.tar.bz2
编译 ./configure
make
配置 export PATH=/你的make路径/make-3.81:$PATH
source /etc/profile
方法三:(下载安装)
sudo apt-get remove make
去这里下载http://packages.ubuntu.com/trusty/make
sudo dpkg -i make*.deb
在用户目录下的.inputrc文件(如果没有,则新建一个)添加:
set meta-flag on
set convert-meta off
set input-meta on
set output-meta on
出错原因是曾使用repo sync从其它库sync过代码,删掉~/.repoconfig即可
rm -rf ~/.repoconfig
*repo init 时提示Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.*
用户错误,repo init,或将没有git库下.git目录下的config配置修改成当前用户邮箱
有好几种处理方法, 取有效的
1. ~/.baserc 下注释掉
#export LC_ALL=C
2.studio/bin/studio.sh 第二行添加
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
前提你的输入法是fcitx
3.AS安装目录下的jre文件替换掉,用2.2.3版本的替换当前版本的(一般3.0可以解决)
Failed to load module "canberra-gtk-module
sudo apt-get install libcanberra-gtk-module
Invoke-customs are only supported starting with Android O (–min-api 26)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Error: Program type already present: android.support.design.widget.CoordinatorLayout$1
包有冲突
在dependencies 中去掉有冲突的包
AndroidStudio 出现 grant current user access to /dev/kvm 以及/dev/kvm devices: permission denies
sudo chmod 777 /dev/kvm
07-26 17:58:39.928 2889 2889 E AndroidRuntime: java.lang.RuntimeException: Unable to start service com.gaei.settings.stat.BootStatService@fe5a3bb with null: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3035)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at android.app.ActivityThread.-wrap17(ActivityThread.java)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5431)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at com.gaei.settings.stat.BootStatService.onStartCommand(BootStatService.java:45)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3018)
07-26 17:58:39.928 2889 2889 E AndroidRuntime: ... 8 more
onStartCommand返回值
onStartComand使用时,返回的是一个(int)整形。
这个整形可以有四个返回值:start_sticky、start_no_sticky、START_REDELIVER_INTENT、START_STICKY_COMPATIBILITY。
它们的含义分别是:
1):START_STICKY:如果service进程被kill掉,保留service的状态为开始状态,但不保留递送的intent对象。随后系统会尝试重新创建service,由于服务状态为开始状态,所以创建服务后一定会调用onStartCommand(Intent,int,int)方法。如果在此期间没有任何启动命令被传递到service,那么参数Intent将为null。2):START_NOT_STICKY:“非粘性的”。使用这个返回值时,如果在执行完onStartCommand后,服务被异常kill掉,系统不会自动重启该服务
3):START_REDELIVER_INTENT:重传Intent。使用这个返回值时,如果在执行完onStartCommand后,服务被异常kill掉,系统会自动重启该服务,并将Intent的值传入。
4):START_STICKY_COMPATIBILITY:START_STICKY的兼容版本,但不保证服务被kill后一定能重启。
onStartComand参数flags含义
flags表示启动服务的方式:
Additional data about this start request. Currently either 0, START_FLAG_REDELIVERY, or START_FLAG_RETRY.START_FLAG_REDELIVERY:如果你实现onStartCommand()来安排异步工作或者在另一个线程中工作, 那么你可能需要使用
START_FLAG_REDELIVERY来让系统重新发送一个intent。这样如果你的服务在处理它的时候被Kill掉, Intent不会丢失.
START_FLAG_RETRY:表示服务之前被设为START_STICKY,则会被传入这个标记。
@Override public int onStartCommand(Intent intent, int flags, int startId) { //super.onStartCommand(intent, flags, startId); return START_REDELIVER_INTENT; }
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.lflex-2.5.39: loadlocale.c:130:_nl_intern_locale_data: ?? 'cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' ???make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] 已放弃 (core dumped)、
在bashrc中添加一句
export LC_ALL=C
"mkimage" command not found - U-Boot images will not be built
make[2]: *** [arch/arm/boot/uImage] Error 1
make[1]: *** [uImage] Error 2
make[1]: Leaving directory `/home/jun/secondDisk/project/android6.0/kernel_imx'
make: *** [out/target/product/sabresd_6dq/kernel] Error 2
按照以往经验,我们需要安装依赖包:
sudo apt-get install uboot-mkimage
但却提示”现在没有可用的软件包 uboot-mkimage,但是它被其它的软件包引用了。 这可能意味着这个缺失的软件包可能已被废弃“
按照其提示,安装”u-boot-tools“即可
sudo apt-get install u-boot-tools
prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld: error: out/host/linux-x86/obj/SHARED_LIBRARIES/libart_intermediates/arch/x86_64/quick_entrypoints_x86_64.o: unsupported reloc 42 against global symbol art::Runtime::instance_
.....
out/host/linux-x86/obj/SHARED_LIBRARIES/libart_intermediates/arch/x86_64/quick_entrypoints_x86_64.o:function art_quick_deoptimize: error: unsupported reloc 42
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [out/host/linux-x86/obj/lib/libart.so] Error 1
cp /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin/ld
Android M引入了Jack (Java Android Compiler Kit),在编译时会启动jack server,优化编译速度等。
如果遇到jack编译错误,可以把$HOME/.jack中的配置文件中的SERVER=true设成false,不用jack,jack现在还不稳定。此外,M对应的是OpenJDK7
修改java版本号也可以解决
target Executable: adb (out/target/product/sabresd_6dq_A39/obj/EXECUTABLES/adb_intermediates/LINKED/adb)
/home/jun/second/sourceCode/code39rel/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lpthread
collect2: error: ld returned 1 exit status
build/core/executable_internal.mk:79: recipe for target 'out/target/product/sabresd_6dq_A39/obj/EXECUTABLES/adb_intermediates/LINKED/adb' failed
make[1]: *** [out/target/product/sabresd_6dq_A39/obj/EXECUTABLES/adb_intermediates/LINKED/adb] Error 1
make[1]: Leaving directory '/home/jun/second/sourceCode/code39rel'
cp: cannot stat 'out/target/product/sabresd_6dq_A39/sabresd_6dq_A39-ota-20160715.zip': No such file or directory
build/core/Makefile:1831: recipe for target 'otapackage' failed
make: *** [otapackage] Error 1
cp /usr/bin/ld.gold prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/…/lib/gcc/arm-linux-androideabi/4.9.x-google/…/…/…/…/arm-linux-androideabi/bin/ld
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-ld: fatal error: out/target/product/sabresd_6dq_A39/obj/lib/crtbegin_so1.o: unsupported ELF machine number 40
bionic/libc/crt.mk:62: recipe for target 'out/target/product/sabresd_6dq_A39/obj/lib/crtbegin_so.o' failed
sudo apt-get install libnl-3-dev
sudo apt-get install libnl-genl-3-dev
/home/jun/second/sourceCode/39rel/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lpthread
collect2: error: ld returned 1 exit status
build/core/executable_internal.mk:79: recipe for target 'out/target/product/sabresd_6dq_A39/obj/EXECUTABLES/adb_intermediates/LINKED/adb' failed
sudo apt-get install lib32z1-dev
vi prebuilts/sdk/tools/jack-admin
找到如下语句:
JACK_SERVER_COMMAND=“java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -cp $LAUNCHER_JAR L A U N C H E R N A M E " 将上述语句修改为: J A C K S E R V E R C O M M A N D = " j a v a − X X : M a x J a v a S t a c k T r a c e D e p t h = − 1 − D j a v a . i o . t m p d i r = LAUNCHER_NAME" 将上述语句修改为: JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir= LAUNCHERNAME"将上述语句修改为:JACKSERVERCOMMAND="java−XX:MaxJavaStackTraceDepth=−1−Djava.io.tmpdir=TMPDIR $JACK_SERVER_VM_ARGUMENTS -Xmx4096m -cp $LAUNCHER_JAR $LAUNCHER_NAME”
主要是添加了-Xmx4096m参数,接下来在源码目录下执行如下命令重启jack-admin服务:
$ ./prebuilts/sdk/tools/jack-admin stop-server
$ ./prebuilts/sdk/tools/jack-admin start-server
07-26 18:14:45.867 2302 2550 W LocationExtManager: at android.os.HandlerThread.run(HandlerThread.java:65)
07-26 18:14:45.867 2302 2550 W LocationExtManager: reconnectService error
07-26 18:14:46.019 1537 2604 I DPMJ : |REQ:RCVR| DPM creating socket
07-26 18:14:42.942 2230 2869 I chatty : uid=1000(system) Thread-3 identical 20 lines
07-26 18:14:44.944 2230 2869 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1611 android.content.ContextWrapper.bindService:698 com.tencent.wecarspeech.sdk.TASConfigManager$a.c:95 com.tencent.wecarspeech.sdk.TASConfigManager$a.b:0 com.tencent.wecarspeech.sdk.TASConfigManager$a$a.run:34
07-26 18:14:46.129 781 6864 I ActivityManager: Force stopping core.system.server.manager.test2 appid=10095 user=0: from pid 7089
07-26 18:14:46.130 781 6864 I ActivityManager: Killing 6887:core.system.server.manager.test2/u0a95 (adj 0): stop core.system.server.manager.test2
07-26 18:14:46.130 781 902 W libprocessgroup: kill(-6887, 9) failed: No such process
07-26 18:14:46.130 781 6864 W ActivityManager: Force removing ActivityRecord{416bee0 u0 core.system.server.manager.test2/core.system.server.manager.test.WatchDogTest t137}: app died, no saved state
07-26 18:14:46.139 505 505 E DisplayDevice: map unknown ((deprecated) sRGB sRGB Full range)/(RenderIntent::COLORIMETRIC) to default color mode
07-26 18:14:46.139 505 505 E DisplayDevice: map unknown ((deprecated) sRGB sRGB Full range)/(RenderIntent::COLORIMETRIC) to default color mode
07-26 18:14:46.142 505 2043 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{9c3205e token=Token{d17b599 ActivityRecord{416bee0 u0 core.system.server.manager.test2/core.system.server.manager.test.WatchDogTest t137}}}#0
07-26 18:14:46.152 781 6864 I ActivityManager: Killing 6917:core.system.server.manager.test2:dfa/u0a95 (adj 500): stop core.system.server.manager.test2
07-26 18:14:46.153 781 6864 W ActivityManager: Scheduling restart of crashed service core.system.server.manager.test2/core.system.server.manager.test.TestService in 1000ms
07-26 18:14:46.154 781 6864 I ActivityManager: Force stopping service ServiceRecord{226261f u0 core.system.server.manager.test2/core.system.server.manager.test.TestService}
在Android8.0之后,Google会对后台服务进行控制,并禁止启动后台服务。提出通过startForegroundService() 启动前台服务。但是必须要配合在service 中调用Service.startForeground(),单纯的使用StartService()方式可能会导致程序崩溃(ANR 或者crash)
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationChannel Channel = new NotificationChannel(CHANNEL_ID, "主服务", NotificationManager.IMPORTANCE_HIGH); Channel.enableLights(true);//设置提示灯 Channel.setLightColor(Color.RED);//设置提示灯颜色 Channel.setShowBadge(true);//显示logo Channel.setDescription("ytzn");//设置描述 Channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); //设置锁屏可见 VISIBILITY_PUBLIC=可见 manager.createNotificationChannel(Channel); Notification notification = new Notification.Builder(this) .setChannelId(CHANNEL_ID) .setContentTitle("主服务")//标题 .setContentText("运行中...")//内容 .setWhen(System.currentTimeMillis()) .setSmallIcon(R.mipmap.ic_launcher)//小图标一定需要设置,否则会报错(如果不设置它启动服务前台化不会报错,但是你会发现这个通知不会启动),如果是普通通知,不设置必然报错 .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .build(); startForeground(1, notification);//服务前台化只能使用startForeground()方法,不能使用 notificationManager.notify(1,notification); 这个只是启动通知使用的,使用这个方法你只需要等待几秒就会发现报错了
aarch64-linux-gnu-gcc: not found
sudo apt install gcc-aarch64-linux-gnu
openssl/opensslv.h: No such file or directory
sudo apt-get install libssl-dev
运行java图形界面报错
Exception in thread “main” java.lang.UnsatisfiedLinkError: /jdk/libawt_xawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
sudo apt install libxtst6:i386
prebuilts/tools/gcc-sdk/gcc: 行 40: prebuilts/tools/gcc-sdk/../../gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux-gcc: 没有那个文件或目录
or
prebuilts/tools/gcc-sdk/../../gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux-g++: No such file or directory
sudo apt-get install ia32-libs
build/core/binary.mk:432: recipe for target 'out/host/linux-x86/obj/EXECUTABLES/validatekeymaps_intermediates/Main.o' failed
do apt-get install lib32z1
out/host/linux-x86/bin/acp: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
do apt-get install libstdc++6
do apt-get install lib32stdc++6
prebuilts/misc/linux-x86/bison/bison: m4 subprocess failed: No such file or directory
do apt-get install bison
do apt-get install libxml2-utils
elzo/lzo1x.h: No such file or directory
do apt-get install liblzo2-dev
fatal error: uuid/uuid.h: 没有那个文件或目录
do apt-get install uuid-dev
zlib.h: 没有那个文件或目录
do apt-get install zlib1g-dev
未找到命令 7z
do apt-get install p7zip
repo init 提示错误(Unable to negotiate with 192.168.100.149 port 29418: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1)
修改~/.ssh/config,加入
[
Host *
KexAlgorithms +diffie-hellman-group1-sha1
]
*repo init时出现Agent admitted failure to sign using the key.*
*Permission denied (publickey).*
出错原因是没有将密钥添加到ssh,在当前用户下执行命令:
ssh-add
即可解决
UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in “/vendor/lib/libledcontroldemo.so”
07-14 04:49:04.224 3868 3868 D AndroidRuntime: Shutting down VM
07-14 04:49:04.225 3868 3868 E AndroidRuntime: FATAL EXCEPTION: main
07-14 04:49:04.225 3868 3868 E AndroidRuntime: Process: com.android.dragonboard.service, PID: 3868
07-14 04:49:04.225 3868 3868 E AndroidRuntime: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/vendor/lib/libledcontroldemo.so"
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:938)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at java.lang.System.load(System.java:1631)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at com.android.dragonboard.service.DragonBoardServiceImpl.<init>(DragonBoardServiceImpl.java:17)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at com.android.dragonboard.service.DragonBoardService.onBind(DragonBoardService.java:51)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at android.app.ActivityThread.handleBindService(ActivityThread.java:3674)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at android.app.ActivityThread.access$1400(ActivityThread.java:195)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1739)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at android.os.Looper.loop(Looper.java:198)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6761)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
07-14 04:49:04.225 3868 3868 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)
07-14 04:49:04.231 3868 3868 I Process : Sending signal. PID: 3868 SIG: 9
1、对应.so文件对应的类,可能被混淆了,造成C/C++中的代码找不到对应的Java类;
hal层服务没启动, 手动启动hal层服务可以解决
07-13 10:55:49.559 866 866 **W PackageManager: Failed to parse /system/app/GaeiSettings**: /system/app/GaeiSettings/GaeiSettings.apk (at Binary XML file line #152): Invalid process name boot_stat in package com.gaei.settings: must have at least one '.' separato
android:process:是否需要在单独的进程中运行,当设置为android:process=”:remote”时,代表Service在单独的进程中运行。注意“:”很重要,它的意思是指要在当前进程名称前面附加上当前的包名,所以“remote”和”:remote”不是同一个意思,前者的进程名称为:remote,而后者的进程名称为:App-packageName:remote。
ReceiverCallNotAllowedException: BroadcastReceiver components are not allowed to bind to services
01-01 08:00:07.195 318 318 D AndroidRuntime: >>>>>> START com.android.internal.os.ZygoteInit uid 0 <<<<<<
01-01 08:00:07.252 318 318 D AndroidRuntime: CheckJNI is ON
07-11 17:24:44.068 1258 1258 I AndroidRuntime: VM exiting with result code 0, cleanup skipped.
07-13 09:41:17.706 1812 1812 D AndroidRuntime: Shutting down VM
07-13 09:41:17.733 1812 1812 E AndroidRuntime: FATAL EXCEPTION: main
07-13 09:41:17.733 1812 1812 E AndroidRuntime: Process: com.gaei.settings, PID: 1812
07-13 09:41:17.733 1812 1812 **E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver com.gaei.settings.BootStatReceiver: android.content.ReceiverCallNotAllowedException: BroadcastReceiver components are not allowed to bind to services**
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2740)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.app.ActivityThread.-wrap14(ActivityThread.java)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5431)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: Caused by: android.content.ReceiverCallNotAllowedException: BroadcastReceiver components are not allowed to bind to services
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.app.ReceiverRestrictedContext.bindService(ContextImpl.java:116)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at com.gac.cloud.analytics.client.StatManagerImpl.b(Unknown)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at com.gac.cloud.analytics.client.StatManagerImpl.a(Unknown)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at com.gac.cloud.analytics.client.StatManager.init(Unknown)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at com.gaei.settings.BootStatReceiver.onReceive(BootStatReceiver.java:28)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2731)
07-13 09:41:17.733 1812 1812 E AndroidRuntime: ... 8 more
Android在广播Boroadcast中, 不能调用BinderService来启动服务
1 bindService不能在BroadcastReceiver 中调用,
2 registerReceiver不能在BroadcastReceiver调用,可以通过context.getApplicationContext().registerReceiver();解决
在里面调用StartService并把要传递参数放到intent中, 然后去startService
IllegalStateException: The specified child already has a parent
290.543 3608 3608 E **AndroidRuntime: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.**
290.543 3608 3608 E AndroidRuntime: at android.view.ViewGroup.addViewInner(ViewGroup.java:4937)
290.543 3608 3608 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4768)
290.543 3608 3608 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4708)
290.543 3608 3608 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4681)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1284)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1557)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1618)
290.543 3608 3608 E AndroidRuntime: at android.app.BackStackRecord.executeOps(BackStackRecord.java:807)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl.executeOps(FragmentManager.java:2386)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2181)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2136)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2043)
290.543 3608 3608 E AndroidRuntime: at android.app.FragmentManagerImpl$1.run(FragmentManager.java:719)
290.543 3608 3608 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:790)
290.543 3608 3608 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
290.543 3608 3608 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
290.543 3608 3608 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6518)
290.543 3608 3608 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
290.543 3608 3608 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
290.543 3608 3608 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:808)
必须要在parent上调用removeView移除掉你要重复使用的这个view才可以,有时候不知道你的view被哪一个parent给绑定了
Fragment中onCreateView方法中, 不能直接返回container对象
public class DragonBoardFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, TextWatcher { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = new View(getActivity()); return view; //return container; } }
IllegalStateException: Cannot broadcast before boot completed
05-29 20:31:23.322 981 981 E AndroidRuntime: FATAL EXCEPTION: main
05-29 20:31:23.322 981 981 E AndroidRuntime: Process: com.core.system.service, PID: 981
05-29 20:31:23.322 981 981 **E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.core.system.service.CoreSystemServer: java.lang.IllegalStateException: Cannot broadcast before boot completed**
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3582)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:200)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6718)
05-29 20:31:23.322 981 981 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
05-29 20:31:23.322 981 981 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Cannot broadcast before boot completed
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.os.Parcel.createException(Parcel.java:1958)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1918)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1868)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.IActivityManager$Stub$Proxy.broadcastIntent(IActivityManager.java:3894)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.ContextImpl.sendBroadcastAsUser(ContextImpl.java:1224)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.ContextImpl.sendBroadcastAsUser(ContextImpl.java:1196)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.content.ContextWrapper.sendBroadcastAsUser(ContextWrapper.java:525)
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.core.system.service.CoreSystemServerImpl.sendStartBroadcast(CoreSystemServerImpl.java:518)
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.core.system.service.CoreSystemServerImpl.<init>(CoreSystemServerImpl.java:223)
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.core.system.service.CoreSystemServer.onCreate(CoreSystemServer.java:37)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3570)
05-29 20:31:23.322 981 981 E AndroidRuntime: ... 8 more
05-29 20:31:23.322 981 981 E AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.android.server.am.ActivityManagerService.verifyBroadcastLocked(ActivityManagerService.java:21942)
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:21974)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.IActivityManager$Stub.onTransact$broadcastIntent$(IActivityManager.java:10171)
05-29 20:31:23.322 981 981 E AndroidRuntime: at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:167)
05-29 20:31:23.322 981 981 E AndroidRuntime: at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3291)
Android不能在开机前发送自定义广播
intent增加FLAG: Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
Intent statusIntent = new Intent(Intent.ACTION_BATTERY_LOW);
statusIntent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendBroadcastAsUser(statusIntent, UserHandle.ALL);