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

一. 工具使用245.使用androidstudio时,不知道什么原因svn不见了

Android Studio missing Subversion plugin

Please make sure that the “SubversionIntegration” plugin is enabled in Preferences > Plugins

248.androidstudio 如何自动import用到的类或接口?For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes:change Insert imports on paste value to AllmarkAdd unambigious imports on the fly option as checkedOn a Mac, do the same thing in Android Studio -> Preferences

参考

251. ubuntu下删除.svn的方法find -type d -name ‘.svn’ -exec rm -rfv {} \;参考 252. Fatal : Could not read from remote repository.

git配置使用,已经把公钥发给发给服务端,在终端命令行也是可以正常的pull push,但是在androidstudio push或者pull的时候确出现上述错误 解决方式 setting –> Version Control –>Git ,In the SSH executable dropdown, choose Native

258.手机root后 还会出现下述情况Android: adb: copy file to /system (Permission denied)

解决方式,需要remount /system mount -o remount,rw /system

261.anroid几个很不错的快捷键二.java及android基础知识246.Error:Execution failed for task ‘:app:dexDebug’.> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘/home/xxx/tools/android/jdk1.7.0_71/bin/java” finished with non-zero exit value 2

检查下是否多次引用同一个jar包 以下情况 1. module下jar包版本不同

同一个module 在libs中包含乐.jar,,而在src下又把相应的source页加入了

gradle中是否重复编译,

比如 已经加了compile fileTree(include: [‘*.jar’], dir: ‘libs’) 然而在下面又加一句compile files(‘libs/xxx.jar’)

参考 Error:Execution failed for task ‘:app:dexDebug’. com.android.ide.common.process.ProcessException

249.Android NDK: Could not find application project directory ! Android NDK: Please define the NDK_PROJECT_PATH variable to point to it./home/cenuser/android/android-ndk-r7b/build/core/build-local.mk:130: *** Android NDK: Aborting . Stop.cd到jni目录。或者 ndk-build -C your_project_path256.Android中如何设置RadioButton在文字的右边,图标在左边

解决方法 : 第一步: android:button=”@null”这条语句将原来系统的RadioButton图标给隐藏起来。 第二步: android:drawableRight=”@android:drawable/btn_radio”这条语句 参考

257.java报“非法字符: \65279 ”错误的解决方法

众所周知,在跨程序的工程中,统一编码是至关重要的,而目前最普遍的则是统一采用“utf8”编码方案。 但是在采用utf8方案的时候,请注意编辑器的自作聪明。 比如editplus。 原因就在于某些编辑器会往utf8文件中添加utf8标记(editplus称其为签名),它会在文件开始的地方插入三个不可见的字符(0xEF 0xBB 0xBF,即BOM),它的表示的是 Unicode 标记(BOM)。 参考

260.android双击back退出{private Toast toast;(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);toast = Toast.makeText(getApplicationContext(), “确定退出?”, 0);}() {quitToast();}() {if(null == toast.getView().getParent()){toast.show();}else{System.exit(0);}}}

或者

private Toast toast; (Bundle savedInstanceState) {…toast = Toast.makeText(this, “再按一次退出应用”, Toast.LENGTH_SHORT);toast.setGravity(Gravity.BOTTOM, 0, ConversionUtil.dip2px(this, 150)); }() {if (doubleBackToExitPressedOnce) {if(toast!=null){toast.cancel();}super.onBackPressed();return;}this.doubleBackToExitPressedOnce = true;toast.show();new Handler().postDelayed(new Runnable() {() {doubleBackToExitPressedOnce=false;}}, 2000); }

参考 Android关于双击退出应用的问题

262.在旧项目中引入android materialdesign 时 出现如下问题

android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.internal.NavigationMenuView Caused by: java.lang.reflect.InvocationTargetException Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f0100c5 a=-1} You need to use a Theme.AppCompat theme (or descendant) with this activity.

解决方法 :使用NavigationMenuView的Activity【一般都是mainActivity】继承自AppCompatActivity,并且修改AndroidManifest.xml中对应activity的theme,使用继承自@style/Theme.AppCompat的主题。

262.How to get key and value of HashMap in java{(String[] args) {// Create a Empty HashMap HashMap<String, String> obHashMap = new HashMap<String, String>();// Put values in hash mapobHashMap.put(“AB”, “1”);obHashMap.put(“EF”, “2”);obHashMap.put(“Gh”, “3”);obHashMap.put(“CD”, “4”);//Store entry (Key/Value)of HashMap in setSet mapSet = (Set) obHashMap.entrySet();//Create iterator on Set Iterator mapIterator = mapSet.iterator();System.out.println(“Display the key/value of HashMap.”);while (mapIterator.hasNext()) {Map.Entry mapEntry = (Map.Entry) mapIterator.next();// getKey Method of HashMap access a key of mapString keyValue = (String) mapEntry.getKey();//getValue method returns corresponding key’s valueString value = (String) mapEntry.getValue();System.out.println(“Key : ” + keyValue + “= Value : ” + value);}}}三.android性能246.android handler的警告Handler Class Should be Static or Leaks Occur

在使用Handler更新UI的时候public class SampleActivity extends Activity {

“人无完人金无足赤”,只要是人就不会是完美的,

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

相关文章:

你感兴趣的文章:

标签云: