Categories
discuss

Build Warning : Mapping new ns to old ns

So, I’m Flutter and on running the App, I receive errors like these in the debug console:

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01

I did flutter clean, but no effect.

I tried the answer here: How to change build tools version in Android Studio

But, when I look for build.gradle file, I have two files one in /android and another in /android/app. But both of these do not have any configuration to change buildToolsVersion.

I did sdkmanager --list_installed and I hae two build-tools versions:

  build-tools;29.0.2   | 29.0.2  | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2  
  build-tools;30.0.2   | 30.0.2  | Android SDK Build-Tools 30.0.2 | build-tools/30.0.2  

What should I do to fix this Warning ?

Also, I am not using Android Studio. I used this guide to install Flutter without Android Studio: How to Install and Configure Flutter Without Android Studio

Answer

Try deleting and reinstalling the SDK platforms. Delete the folders in ~AndroidSdkplatforms and download the SDKs you need.

Edit: The above somehow resolved the issue before, but I ran into the same problem again when more external packages were updated. This time, deleting the SDK platforms didn’t work. Instead, I updated Gradle in two locations in my project:

android/build.gradle

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2' // Update this line
        ...
    }
}

Note: Gradle 7.0.2 is the latest stable release present at this time in Google’s Maven repository. To check for newer versions, visit https://maven.google.com. Under com.android.tools.build > gradle you will find the versions available for Android.

android/gradle/wrapper/gradle-wrapper.properties

...
distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip # Update this line

Updating Gradle in these two spots resolved the issue for me this time. Hope this helps.

Categories
discuss

remove default padding on jetpack compose textfield

I want to customize TextField composable in Jetpack Compose. I am trying to achieve the result in the image below, but somehow TextField has some default paddings which i couldn’t find how to change values of. I want to remove default paddings and customize it

(The image on the right one is the result i achieved. I drew a border so that you can see it has padding, btw below that TextField are just Text composables, they aren’t TextFields)

enter image description here enter image description here

Below is my TextField code

TextField(
    value = "",
    onValueChange = {},
    modifier = Modifier
        .weight(1F)
        .padding(0.dp)
        .border(width = 1.dp, color = Color.Red),
    placeholder = {
        Text(
            "5555 5555 5555 5555", style = TextStyle(
                color = Color.Gray
            )
        )
    },
    colors = TextFieldDefaults.textFieldColors(
        backgroundColor = Color.Transparent,
        unfocusedIndicatorColor = Color.Transparent,
        focusedIndicatorColor = Color.Transparent
    ),
)

Answer

You can use BasicTextField, it’s a plain text field without any decorations. Note that it doesn’t have placeholder/hint too, you have to implement those by yourself if you need.

BasicTextField(value = "", onValueChange = {}, Modifier.fillMaxWidth())
Categories
discuss

Java Stamp on certain location of pdf using iText

I am making a web application using Javascript for the front end and this is how it works:

  1. I start the application and it opens a web page via my browser.

  2. It displays a PDF page obtained from my directory.

  3. I have the option to click on a stamp and drag and move around the pdf and place where ever I want.

  4. When I’m done, I could click Save and it automatically saves the pdf file in my directory.

  5. I can open the pdf file in my folder to view the updated PDF along with the stamp added.

The problem is when I open the PDF file to view, the positioning is not identical to the positioning of the stamp in the web browser.

   

window.dragMoveListener = dragMoveListener;

    interact('.signer-box')
        .draggable({
            onmove: dragMoveListener,
            inertia: true,
            autoScroll: true,
            restrict: {
                elementRect: {top: 0, left: 0, bottom: 1, right: 1}
            }
        })
        .resizable({
            onmove: resizeMoveListener,
            inertia: true,
            edges: {left: true, right: true, bottom: true, top: true}
        })

function dragMoveListener(event) {
    var target = event.target;
    var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx;
    var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
    target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px)';
    target.setAttribute('data-x', x);
    target.setAttribute('data-y', y);
    
    computeSignerBoxPosition();
}

function resizeMoveListener(event) {
    var target = event.target;
    var x = (parseFloat(target.getAttribute('data-x')) || 0);
    var y = (parseFloat(target.getAttribute('data-y')) || 0);
    x += event.deltaRect.left;
    y += event.deltaRect.top;

    target.style.width = event.rect.width + 'px';
    target.style.height = event.rect.height + 'px';
    target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px,' + y + 'px)';
    target.setAttribute('data-x', x);
    target.setAttribute('data-y', y);
    
    computeSignerBoxPosition();
}

function computeSignerBoxPosition() {
    var $signatureBox = $('.signer-box');
    var sbDataX = parseFloat($signatureBox.attr('data-x'));
    var sbDataY = parseFloat($signatureBox.attr('data-y'));
    var sbOuterWidth = $signatureBox.outerWidth();
    var sbOuterHeight = $signatureBox.outerHeight();

    var w = $('#pdf-page').width();
    var h = $('#pdf-page').height();
    
    var top = sbDataX / w;
    var left = sbDataY / h;
    var width = sbOuterWidth / w;
    var height = sbOuterHeight / h;

    document.getElementById("widthValue").value = width;
    document.getElementById("heightValue").value = height;
    document.getElementById("coorX").value = top;
    document.getElementById("coorY").value = left;
}
@charset "UTF-8";

#content{
    text-align: center;
}

#pdf-container {
    display: inline-block;
    width: 100%;
    user-select: none;
}

#pdf-page {
    width: 100%;
}

.signer-box {
    background: url('../images/pen_icon.png') #29e no-repeat 50% 50%;
    background-size: 50%;
    color: white;
    font-size: 20px;
    font-family: sans-serif;
    border-radius: 8px;
    width: 180px;
    height: 150px;
    position:absolute;
    opacity: .8;
    box-sizing: border-box;
    box-shadow: rgb(0, 0, 0, 0.7) 0.2em 0.2em 0.5em;
    -ms-touch-action: none;
    touch-action: none; 
}
  
#signature-pad {
    position: relative;
    width: 100%;
    height: 160px;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#signatureImg{
    width: 100%;
}
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   
        <div id="content">
            <div class="wrap">
                   <hr style="border:15px;"><hr style="border:2px;">
                    
                    <div id="wrapper">
                        <div id="content">
                            <div id="pdf-container" >                   
                                <div id="signers-list">
                                   <div id="signer-1" class="signer-box"></div>
                                </div>                  
                                <img id="pdf-page" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABMgAAAYwCAIAAAAI8uQFAAAzRklEQVR42uzdf2SV/f/A8Q8zySQxyUwykiTJSJLMjMncMhkzkyQxk1uSS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YSwAAADCWAAAAGEsAAACMJQAAAMYSAAAAjCUAAADGEgAAAGMJAACAsQQAAABjCQAAgLEEAADAWAIAAGAsAQAAMJYAAABgLAEAADCWAAAAGEsAAACMJQAAABhLAAAAjCUAAADGEgAAAGMJAAAAxhIAAABjCQAAgLEEAADAWAIAAICxBAAAwFgCAABgLAEAADCWAAAAYCwBAAAwlgAAABhLAAAAjCUAAADGEgAAAIwlAAAAxhIAAABjCQAAgLEEAAAAYwkAAICxBAAAwFgCAABgLAEAAMBYAgAAYCwBAAAwlgAAABhLAAAAMJYAAAAYSwAAAIwlAAAAxhIAAABjCQAAAMYSAAAAYwkAAICxBAAAwFgCAACAsQQAAMBYAgAAYCwBAAAwlgAAAGAsAQAAMJYAAAAYSwAAAIwlAAAAGEsAAACMJQAAAMYSAAAAYwkAAICxBAAAAGMJAACAsQQAAMBYAgAAYCwBAADAWAIAAGAsAQAAMJYAAAAYSwAAADCWAAAAGEsAAACMJQAAAMYSAAAAjCUAAADGEgAAAGMJAACAsQQAAABjCQAAgLEEAADAWAIAAGAsAQAAMJYAAABgLAEAADCWAAAAGEsAAACMJQAAABhLAAAAjCUAAADGEgAAAGMJAAAAxhIAAABjCQAAgLEEAADAWAIAAICxBAAAwFgCAABgLAEAADCWAAAAGEsAAAAwlgAAABhLAAAAjCUAAADGEgAAAIwlAAAAxhIAAABjCQAAgLEEAAAAYwkAAICxBAAAwFgCAABgLAEAAMBYAgAAYCwBAAAwlgAAABhLAAAAjCUAAAAYSwAAAIwlAAAAxhIAAABjCQAAAMYSAAAAYwkAAICxBAAAwFgCAACAsQQAAMBYAgAAYCwBAAAwlgAAAGAsAQAAMJYAAAAYSwAAAIwlAAAAGEsAAACMJQAAAMYSAAAAYwkAAICxBAAAAGMJAACAsQQAAMBYAgAAsBF9Ip71RRoBHwAAAABJRU5ErkJggg==" />
                            </div>  
                        </div>
                    </div>
       
                   
                </table></form>

                    <hr style="border:15px;"><hr style="border:2px;">
                    <div class="content">

                        <table id="customers">
                            <tr>
                                <td>
                                     X:
                                </td>
                                <td>
                                    <input type="text" name="coorX" id="coorX" value="0" readonly="readonly">
                                </td>
                                <td>
                                     h:
                                </td>
                                <td>
                                    <input type="text" name="heightValue" id="heightValue" value="150" readonly="readonly">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                     Y:
                                </td>
                                <td>
                                    <input type="text" name="coorY" id="coorY" value="0" readonly="readonly">
                                </td>
                                <td>
                                     w:
                                </td>
                                <td>
                                    <input type="text" name="widthValue" id="widthValue" value="180" readonly="readonly">
                                </td>
                            </tr>
                        </table>
                        <hr>
              </form>
            </div><!-- /.wrap -->
        </div><!-- /.content -->
         
            </div>
            <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/interact.js/1.2.9/interact.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.worker.min.js'></script>

    </body>
</html>

Below is the back-end code to handle the stamping part using iText:

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
    File file = new File("D:\Documents\pruebaPdf\Ejemplo_Uno.pdf");
            file.getParentFile().mkdirs();
            PdfReader reader = new PdfReader("D:\Documents\pruebaPdf\Ejemplo_Uno.pdf");
     PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("D:\Documents\pruebaPdf\Ejemplo_Dos.pdf"));
             Document document = new Document();
            
            try {
              
   PdfContentByte cb = stamper.getOverContent(request.getParameter("page"));
        
   float top = Float.valueOf(request.getParameter("top"));
  float left = Float.valueOf(request.getParameter("left"));
  float width = Float.valueOf(request.getParameter("width"));
  float height = Float.valueOf(request.getParameter("height"));
    
            // Just in case, take into account page rotation
            Rectangle pdfRectangle = reader.getPageSizeWithRotation(1);
    
            float pdfWidth = pdfRectangle.getWidth();
            float pdfHeight = pdfRectangle.getHeight();
    
            float llx = pdfWidth * left;
            float lly = pdfHeight * (1 - top - height);
            // Until iText 5 this code should work
            float urx = llx + (pdfWidth * width);
            float ury = lly + (pdfHeight * height);
            
           Rectangle rect = new Rectangle(llx, lly, urx, ury);
    
  rect.setBorder(Rectangle.BOX);
  rect.setBorderWidth(1);
  rect.setBackgroundColor(BaseColor.GRAY);
  rect.setBorderColor(BaseColor.GREEN);
  cb.rectangle(rect);
          
  } catch (Exception e) {
                System.out.println("ERROR=>>>>>>" + e);
   }finally{
     stamper.close();
     reader.close();
     document.close();
   }
    
 }

The position where I want the painting to come out enter image description here

the position that I obtain with the coordinates that are calculated enter image description here

Answer

As indicated in this companion question, the goal is to be able to translate the position and dimension of your image relative to the PDF between its representation in the browser and in the actual PDF.

In this specific use case you already have a well defined structure of elements, in which your PDF preview image is displayed in a predictable way.

Following the advice of the aforementioned question, I think you need to take the relevant points of your signature box, say:

var $signatureBox = $('.signer-box');
var sbDataX = parseFloat($signatureBox.attr('data-x'));
var sbDataY = parseFloat($signatureBox.attr('data-y'));
var sbOuterWidth = $signatureBox.outerWidth();
var sbOuterHeight = $signatureBox.outerHeight();

And convert them to percentages relative to the width and height of your PDF image:

var w = $('#pdf-page').width();
var h = $('#pdf-page').height();

var top = sbDataY / h;
var left = sbDataX / w;
var width = sbOuterWidth / w;
var height = sbOuterHeight / h;

I have used values relative to the unit, please, feel free to multiply them by 100 if you prefer to work with percentages. Just take into consideration in the next step.

These relative values top, left, width and height will be sent to your backend.

This information can be computed in your different listeners. Consider for example the definition of a common function that will be used to defined the right form values when either a drag and drop or a resize event occur:

window.dragMoveListener = dragMoveListener;

interact('.signer-box')
        .draggable({
            onmove: dragMoveListener,
            inertia: true,
            autoScroll: true,
            restrict: {
                elementRect: {top: 0, left: 0, bottom: 1, right: 1}
            }
        })
        .resizable({
            onmove: resizeMoveListener,
            inertia: true,
            edges: {left: true, right: true, bottom: true, top: true}
        })

function dragMoveListener(event) {
    var target = event.target;
    var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx;
    var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
    target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px)';
    target.setAttribute('data-x', x);
    target.setAttribute('data-y', y);
    
    computeSignerBoxPosition();
}

function resizeMoveListener(event) {
    var target = event.target;
    var x = (parseFloat(target.getAttribute('data-x')) || 0);
    var y = (parseFloat(target.getAttribute('data-y')) || 0);
    x += event.deltaRect.left;
    y += event.deltaRect.top;

    target.style.width = event.rect.width + 'px';
    target.style.height = event.rect.height + 'px';
    target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px,' + y + 'px)';
    target.setAttribute('data-x', x);
    target.setAttribute('data-y', y);
    
    computeSignerBoxPosition();
}

function computeSignerBoxPosition() {
    var $signatureBox = $('.signer-box');
    var sbDataX = parseFloat($signatureBox.attr('data-x'));
    var sbDataY = parseFloat($signatureBox.attr('data-y'));
    var sbOuterWidth = $signatureBox.outerWidth();
    var sbOuterHeight = $signatureBox.outerHeight();

    var w = $('#pdf-page').width();
    var h = $('#pdf-page').height();
    
    var top = sbDataY / h;
    var left = sbDataX / w;
    var width = sbOuterWidth / w;
    var height = sbOuterHeight / h;

    document.getElementById("widthValue").value = width;
    document.getElementById("heightValue").value = height;
    document.getElementById("coorX").value = left;
    document.getElementById("coorY").value = top;
}

As mentioned, the idea is to compute the information that should be send to the backend when both listeners change. As an optimization, instead of computing the necessary information in the listener, please, consider attach to the button or visual element that you are using to submit your form a click listener that invoke the mentioned computeSignerBoxPosition function prior sending the information to the backend as it is only necessary in that moment.

With that information, as indicated in the original answer, you can obtain the right position like this:

float top = Float.valueOf(request.getParameter("top"));
float left = Float.valueOf(request.getParameter("left"));
float width = Float.valueOf(request.getParameter("width"));
float height = Float.valueOf(request.getParameter("height"));

// Just in case, take into account page rotation
Rectangle pdfRectangle = reader.getPageSizeWithRotation(1);

float pdfWidth = pdfRectangle.getWidth();
float pdfHeight = pdfRectangle.getHeight();

float llx = pdfWidth * left;
float lly = pdfHeight * (1 - top - height);
// Until iText 5 this code should work
float urx = llx + (pdfWidth * width);
float ury = lly + (pdfHeight * height);
// It seems that changed in Itext7 to this (they use just width and height)
// If it is your use case, please, comment the block above 
// and uncomment the following lines
// float urx = pdfWidth * width;
// float ury = pdfHeight * height;

Rectangle rect = new Rectangle(llx, lly, urx, ury);

PdfStampAnnotation stamp = new PdfStampAnnotation(rect).setStampName(new PdfName("Approved"));
PdfFormXObject xObj = new PdfFormXObject(new Rectangle(width,height));
PdfCanvas canvas = new PdfCanvas(xObj,doc);
canvas.addImage(image,0,0,false);

The algorithm takes into consideration that in PDF the lower-left corner of the page coincides with the origin of the coordinate system (0, 0), where positive x values are to the right of the origin and positive y values are above the origin (in contrast with the browser):

PDF coordinate system

The credit for the image is for Bruno Lowagie when he describes how to interpret the coordinates of a rectangle in PDF and where is the origin of a PDF page.

It is important to note as well that the actual dimensions of your image and the PDF page in their representation in the browser and the actual PDF file should be constant, they need to preserve the proper aspect ratio; on the contrary, you need to correct your dimensions by the corresponding factor.

Categories
discuss

After updating Gradle to 7.0.2, Element type “manifest” must be followed by either attribute specifications, “>” or “/>” error

So today I updated Android Studio to:

Android Studio Arctic Fox | 2020.3.1
Build #AI-203.7717.56.2031.7583922, built on July 26, 2021

An I got a ‘Android Gradle Plugin can be upgraded’ notification.

Until now, I was using:

Android Gradle Plugin: 4.2.2
Gradle: 6.9
Java: 8

However, after upgrading I got the error of the question.

My Manifest File looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.hsd.contest.spain.clover.huawei">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true">
        <receiver
            android:name=".AlarmReceiver"
            android:enabled="true"
            android:exported="false" />

        <activity
            android:name=".ConsumeActivity"
            android:excludeFromRecents="true"
            android:launchMode="singleTask"
            android:taskAffinity="" />
        <activity android:name=".MapActivity" />
        <activity
            android:name=".SetTimeActivity"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="portrait" />
        <activity
            android:name=".ActivityAddFreq"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="portrait" />
        <activity
            android:name=".ConfigActivity"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="portrait" />
        <activity
            android:name=".SplashActivity"
            android:configChanges="orientation|keyboardHidden"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="portrait" />

        <meta-data
            android:name="preloaded_fonts"
            android:resource="@array/preloaded_fonts" />
    </application>
</manifest>

Do you have any ideas about why this is happening? Interesting fact: This error only happens in this project.

EDIT My Huawei APIs dependencies are the ones that follow: Module build.gradle

implementation 'com.huawei.agconnect:agconnect-core:1.5.0.300'
implementation 'com.huawei.hms:awareness:1.0.7.303'
implementation 'com.huawei.hms:ml-computer-vision-ocr:2.0.5.300'
implementation 'com.huawei.hms:ml-computer-vision-ocr-latin-model:2.0.5.300'
implementation 'com.huawei.hms:ml-computer-vision-ocr-cn-model:2.0.5.300'
implementation 'com.huawei.hms:location:5.0.4.300'
implementation 'com.huawei.hms:maps:4.0.0.301'
implementation 'com.huawei.hms:site:5.0.5.301'
implementation 'com.huawei.hms:hianalytics:5.0.3.300'
implementation 'com.huawei.hms:ads-lite:13.4.41.304'

Project build.gradle

classpath 'com.huawei.agconnect:agcp:1.4.2.300'

Answer

The real solution I found by using trial and error version to use is

implementation 'com.huawei.agconnect:agcp:1.5.2.300'
Categories
discuss

Hilt viewModel and Compose not working together

It seems like the official Android docs way of using Compose, Hilt and ViewModel injection with Navigation does not work.

I have the following setup:

A main screen, which only hosts the nav controller. The Home screen shows a button to. navigation to the name screen which has a view model.

@Composable
fun MainScreen() {
    val navController = rememberNavController()
    NavHost(navController, startDestination = "home") {
        composable("home") {
            HomeScreen() {
                navController.navigate("my/Name")
            }
        }

        composable("my/{name}") { navBackStackEntry ->
            val viewModel: NameScreenViewModel = hiltViewModel(navBackStackEntry)
            NameScreen(viewModel)
        }
    }
}
@Composable
fun HomeScreen(onButtonClicked: () -> Unit) {
    Button(onClick = onButtonClicked, modifier = Modifier.padding(8.dp)) {
        Text("Continue")
    }
}
@HiltViewModel
class NameScreenViewModel @Inject constructor(private val test: TestClass): ViewModel() {
    var name = MutableLiveData("empty")

    fun change() {
        name.value = test.load()
    }
}

@Composable
fun NameScreen(viewModel: NameScreenViewModel) {
    val name by viewModel.name.observeAsState()

    Column {
        Text("Hi there, $name")

        Button(onClick = { viewModel.change() }) {
            Text("Click me!")
        }
    }
}

Activity and Application have the correct annotations:

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            ComposeViewModelTheme {
                // A surface container using the 'background' color from the theme
                Surface(color = MaterialTheme.colors.background) {
                    MainScreen()
                }
            }
        }
    }
}
@HiltAndroidApp
class MainApplication : Application() {
}

The injected class is very simple and is even registered for being provided instead of using the constructor annotation:

class TestClass {
    fun load(): String {
        return "name"
    }
}
@Module
@InstallIn(SingletonComponent::class)
class AppModule {
    @Provides
    @Singleton
    fun providesTestClass(): TestClass {
        return TestClass()
    }
}

If using hiltViewModel as above, the app will crash with the error

java.lang.IllegalStateException: Given component holder class eu.meecolabs.composeviewmodel.MainActivity does not implement interface dagger.hilt.internal.GeneratedComponent or interface dagger.hilt.internal.GeneratedComponentManager
        at dagger.hilt.EntryPoints.get(EntryPoints.java:62)
        at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.createInternal(HiltViewModelFactory.java:129)
        at androidx.hilt.navigation.HiltViewModelFactory.create(HiltNavBackStackEntry.kt:56)
        at eu.meecolabs.composeviewmodel.ui.ComposableSingletons$MainScreenKt$lambda-1$1.invoke(MainScreen.kt:26)
        at eu.meecolabs.composeviewmodel.ui.ComposableSingletons$MainScreenKt$lambda-1$1.invoke(MainScreen.kt:25)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.navigation.compose.NavHostKt$NavHost$6$1.invoke(NavHost.kt:146)
        at androidx.navigation.compose.NavHostKt$NavHost$6$1.invoke(NavHost.kt:145)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84)
        at androidx.navigation.compose.NavBackStackEntryProviderKt.SaveableStateProvider(NavBackStackEntryProvider.kt:59)
        at androidx.navigation.compose.NavBackStackEntryProviderKt.access$SaveableStateProvider(NavBackStackEntryProvider.kt:1)
        at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:51)
        at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:50)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
        at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:46)
        at androidx.navigation.compose.NavHostKt$NavHost$6.invoke(NavHost.kt:145)
        at androidx.navigation.compose.NavHostKt$NavHost$6.invoke(NavHost.kt:144)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.animation.CrossfadeKt$Crossfade$1$1.invoke(Crossfade.kt:74)
        at androidx.compose.animation.CrossfadeKt$Crossfade$1$1.invoke(Crossfade.kt:69)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.animation.CrossfadeKt.Crossfade(Crossfade.kt:86)
        at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:144)
        at androidx.navigation.compose.NavHostKt$NavHost$7.invoke(Unknown Source:13)
        at androidx.navigation.compose.NavHostKt$NavHost$7.invoke(Unknown Source:10)
        at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:140)
        at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2156)
        at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2399)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2580)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2573)
        at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(SnapshotState.kt:540)
        at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2566)
2021-07-27 17:46:40.678 22501-22501/? E/AndroidRuntime:     at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:2542)
        at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:613)
        at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:764)
        at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:103)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:447)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:416)
        at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
        at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
        at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
        at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:965)
        at android.view.Choreographer.doCallbacks(Choreographer.java:791)
        at android.view.Choreographer.doFrame(Choreographer.java:722)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)

I am using the latest Android Studio Preview and the following dependency versions:

ext {
        compose_version = '1.0.0-rc02'
        hilt_version = '2.38'
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.1.0-alpha04"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"

        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
implementation 'androidx.core:core-ktx:1.6.0'

    implementation 'androidx.appcompat:appcompat:1.3.1'

    implementation 'com.google.android.material:material:1.4.0'

    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"

    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'

    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'

    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07'

    implementation 'androidx.activity:activity-compose:1.3.0-rc02'

    implementation "androidx.navigation:navigation-compose:2.4.0-alpha05"
    implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-alpha03'

    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-compiler:$hilt_version"
    kapt 'androidx.hilt:hilt-compiler:1.0.0'

I really do not know what else to try. I have checked so many different combinations already and read through the hand full or blog posts or SO issues, but all seem to be using outdated libraries or there does not seem to be a real solution.

Answer

The solution seems to be updating dependencies. Since I posted this question, Hilt released v2.38.1 and Compose was released in v1.0.0 (final).

That combination will work as expected. 👍

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..