【问题标题】:Error: package com.lapism.searchview.view does not exist错误:包 com.lapism.searchview.view 不存在
【发布时间】:2016-10-09 04:33:31
【问题描述】:

我在我的项目中使用了 searchview,在 build.gradle 文件中具有依赖项compile 'com.lapism:searchview:3.0.2'。但是当我尝试运行应用程序时,我遇到了一个错误

  1. 错误:com.lapism.searchview.view 包不存在
  2. 错误: 找不到符号类 SearchView
  3. 错误:任务执行失败 ':app:compileDebugJavaWithJavac'。

    我目前的安卓版本是2.1

我的 Build.gradle 文件:

     buildscript {
     repositories 
      {
      maven { url 'https://maven.fabric.io/public' }
      }

     dependencies
     {
     classpath 'io.fabric.tools:gradle:1.+'}
     }

    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'

      android {
      compileSdkVersion 23
      buildToolsVersion "23.0.2"

     defaultConfig {
      multiDexEnabled true
      applicationId "pingo.betnek.mobigrab"
      minSdkVersion 16
      targetSdkVersion 15
      versionCode 2
      versionName "1.1"
          }
          dexOptions
        {
    incremental true
    javaMaxHeapSize "4g"
         }

    buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
         }
       }
      }
         repositories {
          jcenter()
          mavenCentral()
          maven {
          url "https://jitpack.io"
            }
          maven { url 'https://maven.fabric.io/public' }
            }
    dependencies
    {
        provided fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile files('libs/activation.jar')
        compile files('libs/additionnal.jar')
        compile files('libs/mail.jar')
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'io.realm:realm-android:0.87.2'
        compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.lapism:searchview:3.0.2'
        compile 'com.googlecode.libphonenumber:libphonenumber:7.2.7'
        compile 'com.android.support:multidex:1.0.1'
        compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar')
            {
    transitive = true;
             }

    }

【问题讨论】:

  • 你清理并重建了项目吗?您是否将该行插入到正确的 Gradle 文件中? (有2个)
  • 是的@Vucko 我已经完成了 Infinite 次的清理和重建。事实上重建我得到这个错误。我在我的 build.gradle 文件中添加了这个依赖 'compile 'com.lapism:searchview:3.0.2'
  • 你将它添加到什么 build.gradle 中? Module:app 的那个还是 Project 的那个?它应该在 Module:app 中。检查编译行中的拼写错误。毕竟,请在已编辑的问题中发布您的构建 gradle。
  • 是的 build.gradle(Module:app) @Vucko
  • 该死的,我看不出这会失败的原因。您是否尝试过使用 gradle 文件同步项目? Android Studio 中 AVD Manager 左侧的小按钮。

标签: java android compiler-errors package searchview


【解决方案1】:

向我们展示您的代码使用情况..

无论如何,将com.lapism.searchview.view.SearchView 更改为com.lapism.searchview.SearchView,或者只是删除导入并让Android Studio 以正确的命名重新导入它们。

它从 2.3 或任何版本开始被重构..

【讨论】:

    猜你喜欢
    • 2011-10-03
    • 1970-01-01
    • 2014-10-02
    • 2016-06-01
    • 2018-06-21
    • 2020-03-13
    • 2015-06-20
    • 2018-07-31
    相关资源
    最近更新 更多