passy / Android-DirectoryChooser

A directory chooser library for Android.
Apache License 2.0
515 stars 144 forks source link

Unresolved class in the Android Manifest #132

Open 0111101010110 opened 1 year ago

0111101010110 commented 1 year ago

I've tried everything and still get an error. It is an emergency; I have to finish this thing in two days. Help me, please.

== Manifest == <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:dataExtractionRules="@xml/data_extraction_rules"
    android:fullBackupContent="@xml/backup_rules"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    tools:targetApi="31"
    android:theme="@style/Theme.RetryChooseDirectory">
    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <meta-data
            android:name="android.app.lib_name"
            android:value="" />
    </activity>

    <activity android:name="net.rdrei.android.dirchooser.DirectoryChooserActivity"/>
</application>

== build.gradle == plugins { id 'com.android.application' }

android { namespace 'com.example.retrychoosedirectory' compileSdk 32

defaultConfig {
    applicationId "com.example.retrychoosedirectory"
    minSdk 26
    targetSdk 32
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation 'net.rdrei.android.dirchooser:library:3.2@aar'   // ...

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'

}

== Main Activity == package com.example.retrychoosedirectory;

import androidx.activity.result.ActivityResult; import androidx.activity.result.ActivityResultCallback; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toast;

import net.rdrei.android.dirchooser.DirectoryChooserActivity; import net.rdrei.android.dirchooser.DirectoryChooserConfig;

public class MainActivity extends AppCompatActivity { // Global variable private Button clickButton; private final Intent chooserIntent = new Intent(this, DirectoryChooserActivity.class); private static final String TAG = "MainActivity"; private final DirectoryChooserConfig config = DirectoryChooserConfig.builder() .newDirectoryName("DirChooserSample") .allowReadOnlyDirectory(true) .allowNewDirectoryNameModification(true) .build();

// Life Cycle
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    clickButton = findViewById(R.id.button);

    ActivityResultLauncher<Intent> startActivityForResult = registerForActivityResult(
        new ActivityResultContracts.StartActivityForResult(),
        new ActivityResultCallback<ActivityResult>()
        {
            @Override
            public void onActivityResult(ActivityResult result)
            {
                if(result.getResultCode() == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED)
                {
                    Intent idk = result.getData();
                    Log.d(TAG, " >> idk = " + idk);
                }
            }
        }
    );

    chooserIntent.putExtra(DirectoryChooserActivity.EXTRA_CONFIG, config);

    clickButton.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View view)
        {
            startActivityForResult.launch(chooserIntent);
        }
    });
}

}