Android studio错误:错误:(22,0)无法在根项目上找到方法android()

时间:2017-04-20 07:13:43

标签: android

我在这张照片中有错误:

Image

错误的文字是:

  

Android工作室错误:错误:(22,0)找不到根项目参数的方法android()

1 个答案:

答案 0 :(得分:0)

您使用的是错误的build.gradle文件。

在您的顶级文件中,您无法定义Android块。

只需将此部分移到module / build.Gradle文件中即可。

FATAL EXCEPTION: main
                                                                      Process: bookish.mayank.bookish, PID: 1706
                                                                      Theme: themes:{default=overlay:system, iconPack:system, fontPkg:system, com.android.systemui=overlay:system, com.android.systemui.navbar=overlay:system}
                                                                      java.lang.NullPointerException: Attempt to read from null array
                                                                          at android.support.v4.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:135)
                                                                          at android.support.v4.widget.CursorAdapter.getView(CursorAdapter.java:256)
                                                                          at android.widget.AbsListView.obtainView(AbsListView.java:2346)
                                                                          at android.widget.ListPopupWindow$DropDownListView.obtainView(ListPopupWindow.java:1734)
                                                                          at android.widget.ListView.measureHeightOfChildren(ListView.java:1281)
                                                                          at android.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1209)
                                                                          at android.widget.ListPopupWindow.show(ListPopupWindow.java:584)
                                                                          at android.widget.ListPopupWindow$PopupDataSetObserver.onChanged(ListPopupWindow.java:1785)
                                                                          at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
                                                                          at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
                                                                          at android.support.v4.widget.CursorAdapter.swapCursor(CursorAdapter.java:347)
                                                                          at android.support.v4.widget.SimpleCursorAdapter.swapCursor(SimpleCursorAdapter.java:326)
                                                                          at android.support.v4.widget.CursorAdapter.changeCursor(CursorAdapter.java:315)
                                                                          at android.support.v4.widget.CursorFilter.publishResults(CursorFilter.java:68)
                                                                          at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5461)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)