所有AndroidX版本均不同于编译

时间:2019-02-25 18:46:53

标签: flutter

我已经将项目迁移到AndroidX,原因是我遇到了一些错误,但是现在我收到了一个错误循环,表明androidX类的版本与编译版本不同:

public function form()
    {
        if($_POST){    

                 if(!empty($_FILES['userfile']['name']))
                 {
                   $config['upload_path'] = './uploads/';
                   $config['allowed_types'] = 'jpg|jpeg|png|gif';
                   $config['file_name'] = $_FILES['userfile']['name'];
                  $this->upload->initialize($config);
                   $this->load->library('upload',$config); 
                   if($this->upload->do_upload('userfile')){                      
                       $userfile = $_FILES['userfile']['name'];

                   }
                   else
                   {
                       $userfile = '';
                   }
             }
             else
              {
                 $userfile = '';

              }
            $data['name']=$this->input->post('name');
            $data['email']=$this->input->post('email');
            $data['phone']=$this->input->post('phone');
            $data['userfile']=$userfile;
            $this->User_m->form_insert($data);
        }

它始终是一个与众不同的类,我已经尝试过实现此代码,但是每次添加一行代码时,它就会给我另一个不同于编译的类:

Android dependency 'androidx.fragment:fragment' has different version for the compile (1.0.0-rc01) and runtime (1.1.0-alpha04) classpath. You should manually set the same version via DependencyResolution 

5 个答案:

答案 0 :(得分:8)

我遇到过类似的问题,只是在app / build.gradle内部使用此问题解决了

configurations.all {
    resolutionStrategy {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.core') {
                details.useVersion "1.0.1"
            }
            if (details.requested.group == 'androidx.lifecycle') {
                details.useVersion "2.0.0"
            }
            if (details.requested.group == 'androidx.versionedparcelable') {
                details.useVersion "1.0.0"
            }
            if (details.requested.group == 'androidx.fragment') {
                details.useVersion "1.0.0"
            }
            if (details.requested.group == 'androidx.appcompat') {
                details.useVersion "1.0.1"
            }
        }
    }
}

答案 1 :(得分:0)

我已解决将我的项目迁移到gradle.properties中并通过Refactor =>迁移到AndroidX,并将此代码添加到我的app / build.gradle中的错误:

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

答案 2 :(得分:0)

我必须在 android / build.grandle

中升级grandle版本

发件人:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

收件人:

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'
}

答案 3 :(得分:0)

我粘贴了这个... / android / build.gradle(不是... / android / app / build.grade),然后解决了这个问题:

subprojects {
    project.configurations.all {
    resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.core' &&
           !details.requested.name.contains('androidx')) {
        details.useVersion "1.0.1"
            }
    }
    }    
}

答案 4 :(得分:0)

将com.android.tools.build:gradle更改为版本3.3.1可以为我解决此问题