android开发中遇到的问题汇总【七】

212.Android WebView常见问题及解决方案汇总

http://blog.csdn.net/t12x3456/article/details/13769731

213.Android check network connectivity on some tablets crash

java.lang.NullPointerException
at com.xxx.Util.getNetworkState(Util.java:246)

214.What is the equivalent of Eclipse “Custom debug Keystore” in Android studio?
http://stackoverflow.com/questions/17189076/what-is-the-equivalent-of-eclipse-custom-debug-keystore-in-android-studio
215.Android Studio在调试时,修改变量的值 在“Variables”窗口中,选择需要修改的变量,然后右键,选“Set Value…”。快捷键F2
216.打开百度定位导致MyApplication中的初始化重新加载一遍。如果此时有自动登录等,会导致重新登录 而目前的凭证失效
217.android webview和js交互json对象 。通过字符串传递。然后通过jsonobject把字符串生成json对象从中获取数据。
218. Android Studio开发jni ndk

主要有以下三块
1. Javah生成JNI头文件
需要进入到/src/mian 这个目录下 。如果不进入这个目录等会运行javah的时候会提示: 错误: 找不到 ‘com.lcj.ndk_demo_2.HelloNDK’ 的类文件
javah -d jni -classpath ….\build\intermediates\classes\debug com.lcj.ndk_demo_2.HelloNDK
jni 是生成的头文件需要存放的文件夹(一般取名jni才对)
….\build\intermediates\classes\debug 是class所在目录(Build—>Make Project生成的class文件都在这里,这是一个相对路径)
com.lcj.ndk_demo_2.HelloNDK 是class文件的文件名(根据之前的java文件生成的)
参考 http://wenku.baidu.com/view/105474098e9951e79b8927a3.html
2.根据上不生成的.h文件 写.c和makefile
3.ndk-build【这个androidstudio1.2已经集成,可以直接编译ndk,所以多一个选择】
易出现的问题 When running the ndk-build command I get the following error:

Android NDK: Could not find application project directory !    
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it

解决方案

NDK_PROJECT_PATH is an environment variable so you don't have to include in the Android.mkfile. Is nkd-build launched in the project directory?

For more info read the docs in docs/HOWTO.html in the NDK folder where I read

Starting with NDK r4, you can simply place the file under $PROJECT/jni/ and launch the 'ndk-build' script from your project tree.

If you want to use 'ndk-build' but place the file to a different location, use a GNU Make variable override as:

ndk-build NDK_APPLICATION_MK=/path/to/your/Application.mk
219.Android下使用lamemp3库将PCM录音数据压缩为MP3格式
        文章最下面有demo 很不错 通过javah修改下,可以直接用
   来源:    http://ikinglai.blog.51cto.com/6220785/1228730
220.Android Studio 不自动弹起代码提示功能解决办法 do not auto popup code completion

升级后不自动弹起代码提醒功能了,而且变量也不标注颜色,简直是气死我了,Google了各种关键词,都没办法
后来看到有个Power Save Mode,昨天看到笔记本发热厉害就给勾上了,是不是这个原因呢?
取消之后一切正常,看来是省电模式下禁用了这些功能,通过反射来实现代码的autoComplete是会增加CPU运算量。

File–>Power Save Mode .勾掉省电模式
参考:http://blog.csdn.net/ameryzhu/article/details/14105275

221. 百度地图相关 在Genymotion上启动项目时,程序抛出异常
  1. 问题描述:
    1、在Genymotion上启动项目时,程序抛出异常,报错日志为:11-10 09:18:44.577: E/com.btten.base.CrashReportHandler(1298): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1093]: Library ‘/system/lib/libhoudini.so’ not found

  2. 问题分析:
    1、鉴于Genymotion是只支持x86架构的,所以从.so文件入手找问题,项目中导入了jpush的.so配置文件,jpush官网上的解释通常都是http://docs.jpush.cn/pages/viewpage.action?pageId=7864765,新建x86、mips 、armeabi-v7a几个目录,然后把libjpush.so也复制一份过去。尝试之后发现不起作用。

  3. 解决办法:
    1、网上找了很久发现如下办法,下载一个ARM Translation Installer的压缩包,安装到Genymotion上,重启下,重新运行程序,ok,问题顺利解决。简要摘抄步骤如下:
    Download the following ZIPs:
    ARM Translation Installer v1.1 Hosted by FILETRIP(Mirrors) - If you have issues flashing ARM Trnaslation, Try re-downloading from a mirror
    Download the correct GApps for your Android version:
    If you have issues flashing GApps, Try re-downloading from a mirror
    Google Apps for Android 4.4(Mirror)(Download from CM11 Links)(4.4 GApps might be buggy)
    Google Apps for Android 4.3(Mirrors)
    Google Apps for Android 4.2
    Google Apps for Android 4.1
    Next Open your Genymotion VM and go to the Homescreen
    Now Drag&Drop the Genymotion-ARM-Translation.zip onto the Genymotion VM window.
    It should say “File transfer in progress”, once it asks you to flash it click ‘OK’
    Now Reboot your VM using ADB or an app like ROM Toolbox. If nescessary you can simply close the VM window, but I don’t recommend it.

    详情转载地址:http://forum.xda-developers.com/showthread.php?t=2528952

222. 百度地图相关。E/baidumapsdk﹕ Authentication Error errorcode: -1 uid: -1 appid -1 msg: AndroidManifest.xml的application中没有meta-data标签
223. 百度地图相关 百度地图去掉缩放按钮

MapView放在ScrollView中,滚动时出现黑条
http://bbs.lbsyun.baidu.com/forum.php?mod=viewthread&tid=1093
应该GLSurfaceView放在ScrollView内部的问题.1.3.5用View直接绘制没有问题.能否在下版中提供一个底层基于View绘制的MapView

版主,我在想,当滚动用截取当前地图的bitmap.(调用getCurrentMap())然后盖在GLSurface上.但getCurrentMap()操作是异步的,用android自带的View.getDrawingCache()也未能成功获取.上述不成功后,由于需求限制可以对地图不操作,尝试了下能不能再MapView完成地图加载后getCurrentMap()把截图放在ImageView中盖在MapView上,但未能找到相应的监听方法.见贴:http://bbs.lbsyun.baidu.com/viewthread.php?tid=1104&extra=page%3D1.现在改用1.3.5在做.QQ:396920165能否交流下

scrollview内嵌mapview后的滑动问题

百度地图mapview放在scrollview中滑动黑屏

后面我试下了直接用截图功能。mapview设置隐藏,然后方法没被执行。是不是在mapview 不显示的情况下。截图功能不可用?
开始移动前截图覆盖
静态。不可拖动但是可要能点击

建议不要在scroll中使用mapview 因为本身map是用opengl绘制的,这个东西在scroll中存在性能问题,所以导致的体验效果不佳,请考虑改变实现方式。

百度map1.3.5
http://developer.baidu.com/map/reference/index.php?title=Class:android%E6%A0%B8%E5%BF%83%E7%B1%BB/MapView

静态【不可放大缩小】的mapview。点击无效

http://www.cnblogs.com/trinea/archive/2012/11/14/2770433.html

224.Android自定义DataTimePicker(日期选择器) http://blog.csdn.net/wwj_748/article/details/38778631
225.Content-Type: application/x-www-form-urlencoded;

可以通过mitmproty分析

https://www.imququ.com/post/four-ways-to-post-data-in-http.html

四种常见的 POST 提交数据方式

application/x-www-form-urlencoded
multipart/form-data
text/xml
application/json
text/xml

226.androidstudio 升级后无法使用git svn等代码管理工具。

vcs –>Enable Version Control Integration 选择git/subversion 即可

227.androidstudio 升级后发现 编写代码自动提醒功能没了。

原因在于打开了File—>Power Saved Mode,关闭即可。

228.dshow 音频采集
229.kill -SIGKILL PID

强行中止(经常使用杀掉)一个进程标识号为324的进程:
  #kill -9 324
  (2)解除Linux系统的死锁
   在Linux中有时会发生这样一种情况:一个程序崩溃,并且处于死锁的状态。此时一般不用重新启动计算机,只需要中止(或者说是关闭)这个有问题的程序 即可。当kill处于X-Window界面时,主要的程序(除了崩溃的程序之外)一般都已经正常启动了。此时打开一个终端,在那里中止有问题的程序。比 如,如果Mozilla浏览器程序出现了锁死的情况,可以使用kill命令来中止所有包含有Mozolla浏览器的程序。首先用ps命令查找该程序的 PID,然后使用kill命令停止这个程序:
  #kill -SIGKILL XXX
  其中,XXX是包含有Mozolla浏览器的程序的进程标识号。
  (3)使用命令回收内存
  我们知道内存对于系统是非常重要的,回收内存可以提高系统资源。kill命令可以及时地中止一些”越轨”的程序或很长时间没有相应的程序。例如,使用top命令发现一个无用(Zombie)的进程,此时可以使用下面命令:
  #kill -9 XXX
  其中,XXX是无用的进程标识号。
  然后使用下面命令:
  #free
  此时会发现可用内存容量增加了。
  (4)killall命令
  Linux下还提供了一个killall命令,可以直接使用进程的名字而不是进程标识号,例如:
  # killall -HUP inetd

230.android导入eclipse项目后,出现如下问题

1.Error:The project is using an unsupported version of the Android Gradle plug-in (0.12.2). The recommended version is 1.2.3.

classpath ‘com.android.tools.build:gradle:1.2.3’

在build.gradle 根据提示把
dependencies {
classpath ‘com.android.tools.build:gradle:0.12.+’
}

修改为
dependencies {
classpath ‘com.android.tools.build:gradle:1.2.3’
}

2.上面修改后会出现如下错误:

Error:Unable to load class ‘org.codehaus.groovy.runtime.typehandling.ShortTypeHandling’.
Possible causes for this unexpected error include:You are using JDK version ‘java version “1.7.0_71”’. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
Please update to a newer version (e.g. 1.7.0_67).

明明用的就是jdk1.7.0_71[比1.7.0_67还新] 却提示不对,问题起始不在jdk这而是 gradle-wrapper.properties

distributionUrl=http://services.gradle.org/distributions/gradle-1.12-all.zip 估计用的是jdk1.7.0.10

把 distributionUrl=http://services.gradle.org/distributions/gradle-1.12-all.zip
修改为 distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

ok 经过上面两步,从studio导入eclipse项目的正常使用。

231.android 注释模板

Settings–>Editor–>File and Code Templates–>Includes

232.shape中子节点的常用属性
  1. <gradient> 渐变

android:startColor 起始颜色
android:endColor 结束颜色
android:angle 渐变角度,0从上到下,90表示从左到右,数值为45的整数倍默认为0;
android:type 渐变的样式 liner线性渐变 radial环形渐变 sweep

例如:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    type="rectangle">
    <gradient
        android:angle="270"
        android:endColor="#9f36a0"
        android:startColor="#65216a" />
</shape>

2.<corners > 圆角
android:radius 圆角的半径 值越大角越圆

android:topRightRadius 右上圆角半径

android:bottomLeftRadius 右下圆角角半径

android:topLeftRadius 左上圆角半径

android:bottomRightRadius 左下圆角半径
如果你把4个角设成为90的话,那么改图片是一个圆!
3.<solid > 填充
android:color 填充的颜色

4.<stroke > 描边
android:width 描边的宽度
android:color 描边的颜色
android:dashWidth 表示’-‘横线的宽度
android:dashGap 表示’-‘横线之间的距离

参考 http://blog.csdn.net/cs_li1126/article/details/11781577

#

233. GestureOverlayView
234.Animation lInAnim = AnimationUtils.loadAnimation(mActivity, R.anim.push_left_in);

更多问题请关注 android开发遇到问题点滴

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在ViewPager嵌套ListView时,可能会遇到ListView无法滑动的问题,这是因为ViewPager会拦截ListView的滑动事件。解决方法如下: 1. 自定义ListView,重写其onInterceptTouchEvent()方法,返回false,让ViewPager不拦截ListView的滑动事件。 ``` public class MyListView extends ListView { public MyListView(Context context) { super(context); } public MyListView(Context context, AttributeSet attrs) { super(context, attrs); } public MyListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: setParentScrollAble(false); break; case MotionEvent.ACTION_UP: setParentScrollAble(true); break; } return super.onInterceptTouchEvent(ev); } private void setParentScrollAble(boolean flag) { getParent().requestDisallowInterceptTouchEvent(!flag); } } ``` 2. 在ViewPager的适配器,将ListView所在的布局设置为android:descendantFocusability="blocksDescendants",防止ListView获取焦点而导致ViewPager无法滑动。 ``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:descendantFocusability="blocksDescendants"> <com.example.MyListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> ``` 以上两种方法都可以解决ViewPagerListView失效的问题

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值