所以我想参与一些android开发,但是我似乎遇到了Google似乎也没有答案的问题。
首先是我正在关注的Hello World教程。 (https://developer.android.com/training/basics/firstapp/)
因此,我设法通过Hello World MainActivity将默认程序包发送到我的手机,但是一旦尝试添加一些UI元素(并包含它们),当我尝试对其进行编译时,我将收到1条错误和1条警告。
由from tkinter import *
import tkinter as tk
from tkinter import ttk
window = Tk()
window.geometry('1300x700')
window.title('Volumetric Calculator')
areastcboxv = StringVar()
areastcbox = ttk.Combobox(window, textvariable = areastcboxv, values = ('Discrete','Normal','Truncated Normal', 'Log Normal'))
areastcbox.grid(row = 1, column = 2)
areastcbox.set('Discrete')
areastcboxv.trace("w", area_labels)
def area_labels():
if areastcboxv.get() == "Discrete":
lvlabel = Label(text = 'Base Case Value', fg = 'black', bg = 'white', width = 17 ).grid(row = 0, column = 3)
bvlabel = Label(text = 'Standard Dev', fg = 'black', bg = 'white', width = 17 ).grid(row = 0, column = 4)
hvlabel = Label(text = 'High Value', fg = 'black', bg = 'white', width = 17).grid(row = 0, column = 5)
lplabel = Label(text = 'Low Probability', fg = 'black', bg = 'white', width = 17).grid(row = 0, column = 6)
bplabel = Label(text = 'Base Probability', fg = 'black', bg = 'white', width = 17).grid(row = 0, column = 7)
hplabel = Label(text = 'High Probability', fg = 'black', bg = 'white', width = 17, state = DISABLED ).grid(row = 0, column = 8)
elif areastcboxv.get() == "Normal":
lvlabel = Label(text = 'Base Case Value', fg = 'black', bg = 'white', width = 17 ).grid(row = 0, column = 3)
bvlabel = Label(text = 'Standard Dev', fg = 'black', bg = 'white', width = 17 ).grid(row = 0, column = 4)
hvlabel = Label(text = 'High Value', fg = 'black', bg = 'white', width = 17, state = DISABLED ).grid(row = 0, column = 5)
lplabel = Label(text = 'Low Probability', fg = 'black', bg = 'white', width = 17, state = DISABLED ).grid(row = 0, column = 6)
bplabel = Label(text = 'Base Probability', fg = 'black', bg = 'white', width = 17, state = DISABLED ).grid(row = 0, column = 7)
hplabel = Label(text = 'High Probability', fg = 'black', bg = 'white', width = 17, state = DISABLED ).grid(row = 0, column = 8)
elif areastcboxv.get() == "Truncated Normal":
pass
elif areastcboxv.get() == "Log Normal":
pass
window.mainloop()
gradle标志设置的WARNING: ABIs [arm64-v8a,armeabi-v7a,armeabi]
包含此项目未定位的'ARMEABI'。
弄乱了软件包之后,卸载了我所有其他的编码软件并重新启动了PC几次,我注意到当我开始一个新项目时,我会立即收到一个警告,使用MainActivity.java
L20 android.injected.build.abi
警告:无法解析符号“ sample_text” /强制转换 从'findViewById(R.id.sample_text)'到'TextView'是多余的。
我已经尝试过重新安装SDK并安装所有软件包,但我不确定并几乎准备放弃,因此任何帮助将不胜感激。
答案 0 :(得分:0)
您好,我找到了两个有用的链接,指向您对第一个问题的答案,即
警告:ABI [arm64-v8a,armeabi-v7a,armeabi]由 'android.injected.build.abi'gradle标志不包含'ARMEABI' 该项目的目标。 这是最有用的链接 WARNING: ABIs [armeabi-v7a,armeabi] set by 'android.injected.build.abi' gradle flag contained 'ARMEABI' not targeted by this project
第二个TextView tv =(TextView)findViewById(R.id.sample_text);警告:无法解析符号“ sample_text” /将“ findViewById(R.id.sample_text)”强制转换为“ TextView”是多余的。
警告是强制转换TextView,即(TextView)编译时没有任何问题,并且没有通过sample_text的ID查找文本视图,因此请从xml文件中检查textview字段的ID。如果出现该问题,则问题在于它无法编译,并且在您接管警告时将予以解决。
答案 1 :(得分:0)
输入这样的代码,警告将消失enter code here
TextView电视= findViewById(R.id.sample_text);