Android Studio Cannot find declaration to go to问题的解决

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_27809865/article/details/80853342

当你打开Android Studio 打开您昨天编写的代码及布局时发现:哎怎么报错了!明明所有文件都在而且没有任何问题 点击Ctrl+左键 提示:Cannot find declaration to go to  那么您就跟着我们步骤来吧!

第一步:点击File 找到 Invalidate Caches / Restart.. 然后Android Studio 将会重新启动 


当你重启完成后发现 Solve Perfectly  没错就是一部解决

展开阅读全文

Android Studio could not find class

08-18

![图片说明](https://img-ask.csdn.net/upload/201608/18/1471505027_514933.png)rn一个CheckBox 多选按钮实现程序,layout预览没有问题,启动APK不能运行。rnrnbuild.gradlern![图片说明](https://img-ask.csdn.net/upload/201608/18/1471511535_934926.png)rnrnlogcat:rnrn08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$superrn08-18 05:15:38.900 3020-3020/com.example.administrator.myapplication12 E/AndroidRuntime: FATAL EXCEPTION: mainrn Process: com.example.administrator.myapplication12, PID: 3020rn java.lang.RuntimeException: Unable to start activity ComponentInfocom.example.administrator.myapplication12/com.example.administrator.myapplication12.MainActivity: java.lang.NullPointerExceptionrn at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)rn at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)rn at android.app.ActivityThread.access$800(ActivityThread.java:135)rn at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)rn at android.os.Handler.dispatchMessage(Handler.java:102)rn at android.os.Looper.loop(Looper.java:136)rn at android.app.ActivityThread.main(ActivityThread.java:5017)rn at java.lang.reflect.Method.invokeNative(Native Method)rn at java.lang.reflect.Method.invoke(Method.java:515)rn at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)rn at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)rn at dalvik.system.NativeStart.main(Native Method)rn Caused by: java.lang.NullPointerExceptionrn at com.example.administrator.myapplication12.MainActivity.onCreate(MainActivity.java:39)rn at android.app.Activity.performCreate(Activity.java:5231)rn at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)rn at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)rn at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) rn at android.app.ActivityThread.access$800(ActivityThread.java:135) rn at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) rn at android.os.Handler.dispatchMessage(Handler.java:102) rn at android.os.Looper.loop(Looper.java:136) rn at android.app.ActivityThread.main(ActivityThread.java:5017) rn at java.lang.reflect.Method.invokeNative(Native Method) rn at java.lang.reflect.Method.invoke(Method.java:515) rn at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) rn at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) rn at dalvik.system.NativeStart.main(Native Method) rn 问答

关于cannot find -lqte-mt 的问题。。。。。。。。。。。。。。。。

04-10

系统是RH9,我按照网上给的一个步骤安装了qt(安装步骤如下),都没什么问题,安装成功。但是我在编译我的程序的时候提示g++ -o xiankong data_receive.o myevent.o xiankong.o xiankongTest.o xiankongbase.o moc_xiankong.o moc_xiankongbase.o -L/opt/FriendlyARM/x86-qtopia/qt/lib -lqte-mt -lpthreadrn/usr/bin/ld: cannot find -lqte-mtrncollect2: ld returned 1 exit statusrnmake: *** [xiankong] Error 1,rn这个好像是没有多线程库支持的吧。。。(我新手,不懂,请指教。。。)于是我查了qt/lib下的几个文件,发现只有libqte.so(.*)这几个文件。按理说我安装的时候是-thread的啊,那应该有libqte-mt.so(.*)的几个文件啊,为什么没有呢???rnrn**************************************************************************************************************rn1、完全安装RHLinux 9,不然后面很麻烦,很多问题都处在这里;如果你就是不完全安装,也不用担心,后面给出了方法。rn2、准备安装Qtopia所需要的软件 rn◆ Qtopia 1.7.0; rn◆ Tmake 1.11 (编译Qtopia时要用到) ; rn◆ Qt/Embedded 2.3.7(Qtopia 1.7.0是基于该开发平台上开发的); rn◆ Qt 2.3.2 for X11(在X11环境下使用其虚拟帧缓冲); rn这里要注意几个软件版本的对应关系,上面是我使用的版本,虽然很旧,但是可以安装。 rn3、开始安装 rn首先,我们在$HOME目录中建立三个目录 rncd $HOME rnmkdir Qt_src rnmkdir Qt_x86 rnmkdir Qt_arm rn其中,Qt_src存放源文件,Qt_x86存放宿主机上虚拟Qt环境,Qt_arm存放目标板Qt环境。我们可以将下载到的源文件全部放在Qt_src目录中。 rnrn解压源文件 rncd $HOME/Qt_x86 rn解压Qt 2.3.2 for X11 rntar zxfv ../Qt_src/qt-x11-2.3.2.tar.gz rnmv qt-2.3.2 qt-2.3.2-x11 rn解压Qt/Embedded 2.3.7 rntar zxfv ../Qt_src/qt-embedded-2.3.7.tar.gz rnmv qt-2.3.7 qt-2.3.7-emb rn解压Qtopia 1.7.0 rntar zxfv ../Qt_src/qtopia-free-1.7.0.tar.gz rn解压Tmake 1.11 rncd qt-2.3.7-emb rnrm –rf tmake rntar zxfv ../../Qt_src/tmake-1.11.tar.gz rnmv tmake-1.11 tmake rnrn设置环境变量 rncd $HOME/Qt_x86 rnexport REAL_QTDIR="$PWD/qt-2.3.2-x11" rnexport REAL_QTEDIR="$PWD/qt-2.3.7-emb" rnexport REAL_QPEDIR="$PWD/qtopia-free-1.7.0" rnexport PATH="$REAL_QPEDIR/bin:$REAL_QTEDIR/bin:$REAL_QTDIR/bin:$PATH" rnexport PATH="$REAL_QTEDIR/tmake/bin:$PATH" rnexport TMAKEPATH="$REAL_QTEDIR/tmake/lib/qws/linux-generic-g++" rnexport LD_LIBRARY_PATH="$REAL_QPEDIR/lib:$REAL_QTEDIR/lib: rn$REAL_QTDIR/lib:$LD_LIBRARY_PATH" rnrn********************************************************* rn编译qt-x11 rnrnrnexport QTDIR=$REAL_QTDIR rncd $REAL_QTDIR rn./configure -no-opengl -no-xft –thread 这里需要注意,一定要有-no-xft,否则编译通不过; rnmake rnrnmake -C tools/qvfb rnmv tools/qvfb/qvfb bin rncp bin/uic $REAL_QTEDIR/bin rncd .. rnrn********************************************************* rn编译qt-emb rnrnexport QTDIR=$REAL_QTEDIR rnexport QTEDIR=$REAL_QTEDIR rnexport QPEDIR=$REAL_QPEDIR rnrncd $REAL_QTEDIR rncp $REAL_QPEDIR/src/qt/qconfig-qpe.h src/tools/ rn./configure -qconfig qpe -system-jpeg -gif \ rn-qvfb -thread -depths 4,8,16,32 rnrnmake sub-src rn编译成功之后没有什么提示,再 rnmake rn成功之后出现 Enjoy! …… 字样 rn********************************************************* rn编译qtopia rnrnexport QTDIR=$REAL_QTEDIR rnexport QTEDIR=$REAL_QTEDIR rnexport QPEDIR=$REAL_QPEDIR rnrncd $REAL_QPEDIR/src rn./configure rnrnmake rnrn如果不出意外,安装应该没有问题。 rn*************************************************************************rnrn另,我的Makefile 如下:rnrnCC = gccrnCXX = g++rnCFLAGS = -pipe -Wall -W -O2 -D_REENTRANT -DNO_DEBUG -DQT_THREAD_SUPPORTrnCXXFLAGS= -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -D_REENTRANTrn-DNO_DEBUG -DQT_THREAD_SUPPORTrnINCPATH = -I$(QTDIR)/includernLINK = gccrnLFLAGS =rnLIBS = $(SUBLIBS) -L$(QTDIR)/lib -lqte-mt -lpthreadrnMOC = $(QTDIR)/bin/mocrnUIC = $(QTDIR)/bin/uicrnrnTAR = tar -cfrnGZIP = gzip -9frn 论坛

没有更多推荐了,返回首页