简体   繁体   English

Android首次设置警告变成错误

[英]Android first time setup warning turns into errors

So i wanted to dive into some android development but i seem to be running into a problem that google doesn't seem to have answers too. 所以我想深入研究一些Android开发,但是我似乎遇到了Google似乎也没有答案的问题。

First up here is the Hello World tutorial i'm following. 首先是我正在关注的Hello World教程。 ( https://developer.android.com/training/basics/firstapp/ ) https://developer.android.com/training/basics/firstapp/

So i managed to send the default package to my phone with the Hello World MainActivity but once i try to add some UI elements (and contain them) I get 1 error and 1 warning when i try to compile it. 因此,我设法使用Hello World MainActivity将默认程序包发送到手机,但是一旦尝试添加一些UI元素(并包含它们),当我尝试对其进行编译时,我将收到1错误和1警告。 WARNING: ABIs [arm64-v8a,armeabi-v7a,armeabi] set by android.injected.build.abi gradle flag contained 'ARMEABI' not targeted by this project. WARNING: ABIs [arm64-v8a,armeabi-v7a,armeabi]android.injected.build.abi gradle标志设置的WARNING: ABIs [arm64-v8a,armeabi-v7a,armeabi]包含此项目未定位的'ARMEABI'。

After messing around with the packages, uninstalling all my other coding software and restarting my PC a few times i noticed when i would start a new project i would have a warning straight away, With my MainActivity.java 在弄乱了软件包之后,卸载了我所有其他的编码软件并重新启动了PC几次,我注意到当我开始一个新项目时,使用MainActivity.java会立刻发出警告。

L20 TextView tv = (TextView) findViewById(R.id.sample_text); L20 TextView tv = (TextView) findViewById(R.id.sample_text);

Warning: Cannot resolve symbol 'sample_text' / Casting 'findViewById(R.id.sample_text)' to 'TextView' is redundant. 警告:无法解析符号“ sample_text” /将“ findViewById(R.id.sample_text)”强制转换为“ TextView”是多余的。

I've tried reinstalling the SDK and installing all the packages but i'm not to sure and am almost ready to give up sadly so any help will be GREATLY appreciated. 我已经尝试过重新安装SDK并安装所有软件包,但是我不确定并几乎准备放弃,因此对您的帮助将不胜感激。

Hello i have found two helpful links to your answer for The first question ie 您好,我找到了两个有用的链接指向您的第一个问题的答案,即

WARNING: ABIs [arm64-v8a,armeabi-v7a,armeabi] set by 'android.injected.build.abi' gradle flag contained 'ARMEABI' not targeted by this project. 警告:由'android.injected.build.abi'gradle标志设置的ABI [arm64-v8a,armeabi-v7a,armeabi]包含了该项目未针对的'ARMEABI'。 here is most helpful link WARNING: ABIs [armeabi-v7a,armeabi] set by 'android.injected.build.abi' gradle flag contained 'ARMEABI' not targeted by this project 这是最有用的链接警告:“ android.injected.build.abi” gradle标记设置的ABI [armeabi-v7a,armeabi]包含此项目未针对的“ ARMEABI”

for the second one TextView tv = (TextView) findViewById(R.id.sample_text); 对于第二个TextView tv =(TextView)findViewById(R.id.sample_text); Warning: Cannot resolve symbol 'sample_text' / Casting 'findViewById(R.id.sample_text)' to 'TextView' is redundant. 警告:无法解析符号“ sample_text” /将“ findViewById(R.id.sample_text)”强制转换为“ TextView”是多余的。

one is warning of casting TextView ie (TextView) this doesn't have any problem on compilation and its not finding text view by id of sample_text so check id of your textview field from xml file. 一个警告是强制转换TextView,即(TextView)编译时没有任何问题,并且没有通过sample_text的ID查找文本视图,因此请从xml文件中检查textview字段的ID。 If its there the problem is its not compiling and it will be solved when you take over the warning. 如果它在那里,则问题在于其未编译,并且在您接管警告时将解决该问题。

enter code like this the warning will disappear enter code here 像这样输入代码警告会消失enter code here

TextView tv = findViewById(R.id.sample_text); TextView电视= findViewById(R.id.sample_text);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM